From 5c587dc5a798cf633320f0c103fc61814466c84f Mon Sep 17 00:00:00 2001 From: hektor Date: Sun, 8 Nov 2026 18:05:08 +0100 Subject: [PATCH] feat(reference-manager): replace 'Zotero' with 'papis' --- home/hosts/astyanax/default.nix | 2 +- home/modules/default.nix | 5 + home/modules/reference-manager/bbt.json | 101 --------------------- home/modules/reference-manager/default.nix | 73 +++------------ hosts/andromache/default.nix | 21 ++--- hosts/astyanax/default.nix | 13 +-- modules/readings/default.nix | 45 +++++++++ 7 files changed, 79 insertions(+), 181 deletions(-) delete mode 100644 home/modules/reference-manager/bbt.json create mode 100644 modules/readings/default.nix diff --git a/home/hosts/astyanax/default.nix b/home/hosts/astyanax/default.nix index fda0d05..d71913c 100644 --- a/home/hosts/astyanax/default.nix +++ b/home/hosts/astyanax/default.nix @@ -47,6 +47,7 @@ nfc.enable = true; nvim.enable = true; pandoc.enable = true; + reference-manager.enable = true; secrets.enable = true; shell = { enable = true; @@ -56,7 +57,6 @@ deploy.enable = true; taskwarrior.enable = true; terminal.enable = true; - reference-manager.enable = true; programs = { home-manager.enable = true; diff --git a/home/modules/default.nix b/home/modules/default.nix index 6e314c6..3b2a649 100644 --- a/home/modules/default.nix +++ b/home/modules/default.nix @@ -20,6 +20,11 @@ default = config.home.username; }; + readings.path = lib.mkOption { + default = "${config.home.homeDirectory}/doc/readings"; + type = lib.types.str; + }; + nixgl.wrap = lib.mkOption { type = lib.types.functionTo lib.types.package; default = if config.lib ? nixGL then config.lib.nixGL.wrap else lib.id; diff --git a/home/modules/reference-manager/bbt.json b/home/modules/reference-manager/bbt.json deleted file mode 100644 index 8d27ac5..0000000 --- a/home/modules/reference-manager/bbt.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "config": { - "options": {}, - "preferences": { - "ascii": "", - "asciiBibLaTeX": false, - "asciiBibTeX": true, - "autoAbbrev": false, - "autoExport": "immediate", - "autoExportDelay": 5, - "autoExportIdleWait": 10, - "autoExportPathReplaceDiacritics": false, - "autoExportPathReplaceDirSep": "-", - "autoExportPathReplaceSpace": " ", - "automaticTags": true, - "auxImport": false, - "baseAttachmentPath": "/home/h/doc/readings", - "biblatexExtendedDateFormat": true, - "biblatexExtendedNameFormat": true, - "biblatexExtractEprint": true, - "biblatexUsePrefix": true, - "bibtexEditionOrdinal": false, - "bibtexParticleNoOp": false, - "bibtexURL": "off", - "cache": true, - "cacheDelete": false, - "charmap": "", - "chinese": false, - "chineseSplitName": true, - "citeCommand": "cite", - "citekeyCaseInsensitive": true, - "citekeyFold": true, - "citekeyFormat": "zotero.clean", - "citekeyFormatEditing": "zotero.clean", - "citekeySearch": false, - "citekeyUnsafeChars": "\\\"#%'(),={}~", - "csquotes": "", - "DOIandURL": "both", - "exportBibTeXStrings": "off", - "exportBraceProtection": true, - "exportSort": "citekey", - "exportTitleCase": true, - "extraMergeCitekeys": false, - "extraMergeCSL": false, - "extraMergeTeX": false, - "fillKeyAfter": 1, - "git": "config", - "import": true, - "importBibTeXStrings": true, - "importCaseProtection": "as-needed", - "importCitationKey": true, - "importDetectURLs": true, - "importExtra": true, - "importJabRefAbbreviations": true, - "importJabRefStrings": true, - "importNoteToExtra": "", - "importPlaceEvent": "inproceedings,conference,presentation,talk", - "importSentenceCase": "on+guess", - "importSentenceCaseQuoted": true, - "importUnknownTexCommand": "ignore", - "itemObserverDelay": 5, - "jabrefFormat": 0, - "japanese": false, - "keyScope": "global", - "language": "langid", - "logEvents": false, - "mapMath": "", - "mapText": "", - "packages": "", - "parseParticles": true, - "patchDates": "dateadded=dateAdded, date-added=dateAdded, datemodified=dateModified, date-modified=dateModified", - "platform": "lin", - "postscript": "", - "postscriptOverride": "", - "preferencesOverride": "", - "qualityReport": false, - "quickCopyEta": "", - "quickCopyMode": "citekeys", - "quickCopyOrgMode": "zotero", - "quickCopyPandocBrackets": false, - "quickCopySelectLink": "zotero", - "rawImports": false, - "rawLaTag": "#LaTeX", - "relativeFilePaths": false, - "remigrate": false, - "resetKeyOnChange": false, - "scrubDatabase": false, - "separatorList": "and", - "separatorNames": "and", - "skipFields": "", - "skipWords": "a,ab,aboard,about,above,across,after,against,al,along,amid,among,an,and,anti,around,as,at,before,behind,below,beneath,beside,besides,between,beyond,but,by,d,da,das,de,del,dell,dello,dei,degli,della,dell,delle,dem,den,der,des,despite,die,do,down,du,during,ein,eine,einem,einen,einer,eines,el,en,et,except,for,from,gli,i,il,in,inside,into,is,l,la,las,le,les,like,lo,los,near,nor,of,off,on,onto,or,over,past,per,plus,round,save,since,so,some,sur,than,the,through,to,toward,towards,un,una,unas,under,underneath,une,unlike,uno,unos,until,up,upon,versus,via,von,while,with,within,without,yet,zu,zum", - "startupProgress": "popup", - "strings": "", - "stringsOverride": "", - "testing": false, - "verbatimFields": "url,doi,file,pdf,ids,eprint,/^verb[a-z]$/,groups,/^citeulike-linkout-[0-9]+$/, /^bdsk-url-[0-9]+$/", - "warnBulkModify": 10, - "warnTitleCased": false - } - } -} diff --git a/home/modules/reference-manager/default.nix b/home/modules/reference-manager/default.nix index ee05d32..fa01825 100644 --- a/home/modules/reference-manager/default.nix +++ b/home/modules/reference-manager/default.nix @@ -1,67 +1,20 @@ +{ config, lib, ... }: + { - config, - inputs, - lib, - pkgs, - ... -}: - -let - betterBibtex = pkgs.fetchzip (finalAttrs: { - pname = "zotero-better-bibtex"; - version = "9.0.64"; - url = "https://github.com/retorquere/zotero-better-bibtex/releases/download/v${finalAttrs.version}/zotero-better-bibtex-${finalAttrs.version}.xpi"; - hash = "sha256-eu/lkWdW/wbehBjk/5ERnKxBob6yaoS4qsh75RaQx5A="; - extension = "zip"; - stripRoot = false; - }); - - hasBrowser = - name: - lib.elem name [ - config.browser.primary - config.browser.secondary - ]; - - zoteroConnector = - inputs.firefox-addons.packages.${pkgs.stdenv.hostPlatform.system}.zotero-connector; - zoteroAddonId = "zotero@chnm.gmu.edu"; - - connectorExtension = { - profiles.default.extensions.packages = [ zoteroConnector ]; - policies.ExtensionSettings.${zoteroAddonId}.default_area = "navbar"; - }; -in -{ - options.reference-manager.enable = lib.mkEnableOption "reference manager (Zotero)"; + options.reference-manager.enable = lib.mkOption { default = false; }; config = lib.mkIf config.reference-manager.enable { - home = { - packages = [ pkgs.zotero ]; - file = { - ".zotero/bbt.json".source = ./bbt.json; - ".zotero/zotero/profiles.ini".text = lib.generators.toINI { } { - General = { - StartWithLastProfile = 1; - Version = 2; - }; - Profile0 = { - Name = "default"; - IsRelative = 1; - Path = "default"; - Default = 1; - }; - }; - - ".zotero/zotero/default/extensions/better-bibtex@iris-advies.com".source = betterBibtex; - ".zotero/zotero/default/user.js".text = '' - user_pref("extensions.startupScanScopes", 1); - user_pref("extensions.autoDisableScopes", 14); - ''; + programs.papis = { + enable = true; + libraries.papers = { + isDefault = true; + settings.dir = "${config.readings.path}/papis"; + }; + settings = { + unique-document-keys = ''["ref"]''; + bibtex-ignore-keys = ''["abstract", "note", "csl_type", "collections", "tags", "files"]''; + add-folder-name = "{doc[ref]}"; }; }; - - programs.firefox = lib.mkIf (hasBrowser "firefox") connectorExtension; - programs.librewolf = lib.mkIf (hasBrowser "librewolf") connectorExtension; }; } diff --git a/hosts/andromache/default.nix b/hosts/andromache/default.nix index 7112eb0..6dbeca9 100644 --- a/hosts/andromache/default.nix +++ b/hosts/andromache/default.nix @@ -24,7 +24,11 @@ in inherit (meta) host; - hardware.facter.reportPath = ./facter.json; + hardware = { + facter.reportPath = ./facter.json; + cpu.intel.updateMicrocode = true; + hackrf.enable = true; + }; "ai-tools".enable = true; anki.enable = true; @@ -78,15 +82,12 @@ in }; ssh.enable = true; storage.enable = true; - syncthing = { + readings = { enable = true; - folders.readings = { - path = "/home/${config.host.username}/doc/readings"; - devices = [ - "astyanax" - "boox" - ]; - }; + peers = [ + "astyanax" + "boox" + ]; }; tailscale.enable = true; taskwarrior.enable = true; @@ -113,8 +114,6 @@ in }; }; - hardware.cpu.intel.updateMicrocode = true; - boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; services.locate = { diff --git a/hosts/astyanax/default.nix b/hosts/astyanax/default.nix index 357b8e7..701bdcb 100644 --- a/hosts/astyanax/default.nix +++ b/hosts/astyanax/default.nix @@ -62,15 +62,12 @@ in secrets.enable = true; ssh.enable = true; storage.enable = true; - syncthing = { + readings = { enable = true; - folders.readings = { - path = "/home/${config.host.username}/doc/readings"; - devices = [ - "andromache" - "boox" - ]; - }; + peers = [ + "andromache" + "boox" + ]; }; taskwarrior.enable = true; wol.wakes = [ "andromache" ]; diff --git a/modules/readings/default.nix b/modules/readings/default.nix new file mode 100644 index 0000000..8224c7c --- /dev/null +++ b/modules/readings/default.nix @@ -0,0 +1,45 @@ +{ config, lib, ... }: + +let + inherit (config.host) username; + home = config.users.users.${username}.home; + devices = builtins.attrNames (import ../syncthing/devices.nix); +in +{ + options.readings = { + enable = lib.mkOption { + default = false; + type = lib.types.bool; + }; + path = lib.mkOption { + default = "${home}/doc/readings"; + type = lib.types.str; + }; + peers = lib.mkOption { + type = lib.types.nonEmptyListOf (lib.types.enum devices); + }; + }; + + config = lib.mkIf config.readings.enable { + assertions = [ + { + assertion = !builtins.elem config.host.name config.readings.peers; + message = "'readings.peers' for ${config.host.name} should not include '${config.host.name}'."; + } + ]; + + syncthing = { + enable = true; + folders.readings = { + inherit (config.readings) path; + devices = config.readings.peers; + }; + }; + + home-manager.sharedModules = [ + { + readings.path = lib.mkDefault config.readings.path; + } + ]; + }; +}