From 131f4e22c30c114378dcf6191cb75c97eba673d0 Mon Sep 17 00:00:00 2001 From: June Stepp Date: Tue, 23 Sep 2025 10:40:17 -0500 Subject: [PATCH] anki: rename `sync.passwordFile`, improve documentation The account password is different from the sync key needed here. Add instructions for how to get the sync key, and make the option name accurate. --- modules/programs/anki/default.nix | 24 +++++++++++++++++++-- modules/programs/anki/helper.nix | 2 +- tests/modules/programs/anki/full-config.nix | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/modules/programs/anki/default.nix b/modules/programs/anki/default.nix index 9d6941c57..8b202683e 100644 --- a/modules/programs/anki/default.nix +++ b/modules/programs/anki/default.nix @@ -17,6 +17,13 @@ in { meta.maintainers = [ lib.maintainers.junestepp ]; + imports = [ + (lib.mkRenamedOptionModule + [ "programs" "anki" "sync" "passwordFile" ] + [ "programs" "anki" "sync" "keyFile" ] + ) + ]; + options.programs.anki = { enable = lib.mkEnableOption "Anki"; @@ -208,10 +215,23 @@ in description = "Path to a file containing the sync account username."; }; - passwordFile = lib.mkOption { + keyFile = lib.mkOption { type = with lib.types; nullOr path; default = null; - description = "Path to a file containing the sync account password."; + description = '' + Path to a file containing the sync account sync key. This is different from + the account password. + + To get the sync key, follow these steps: + + - Enable this Home Manager module: `programs.anki.enable = true` + - Open Anki. + - Navigate to the sync settings page. (Tools > Preferences > Syncing) + - Log in to your AnkiWeb account. + - Select "Yes" to the prompt about saving preferences and syncing. + - A Home Manager warning prompt will show. Select "Show details...". + - Get your sync key from the message: "syncKey changed from \`None\` to \`\`" + ''; }; url = lib.mkOption { diff --git a/modules/programs/anki/helper.nix b/modules/programs/anki/helper.nix index e3f4d26b2..d40c5a965 100644 --- a/modules/programs/anki/helper.nix +++ b/modules/programs/anki/helper.nix @@ -164,7 +164,7 @@ in if cfg.sync.usernameFile == null then "None" else "Path('${cfg.sync.usernameFile}')" } key_file: Path | None = ${ - if cfg.sync.passwordFile == null then "None" else "Path('${cfg.sync.passwordFile}')" + if cfg.sync.keyFile == null then "None" else "Path('${cfg.sync.keyFile}')" } custom_sync_url: str | None = ${if cfg.sync.url == null then "None" else "'${cfg.sync.url}'"} diff --git a/tests/modules/programs/anki/full-config.nix b/tests/modules/programs/anki/full-config.nix index d7f815289..490f418d7 100644 --- a/tests/modules/programs/anki/full-config.nix +++ b/tests/modules/programs/anki/full-config.nix @@ -1,7 +1,7 @@ { pkgs, ... }: let # This would normally not be a file in the store for security reasons. - testPasswordFile = pkgs.writeText "test-password-file" "password"; + testKeyFile = pkgs.writeText "test-key-file" "a-sync-key"; in { programs.anki = { @@ -37,7 +37,7 @@ in networkTimeout = 60; url = "http://example.com/anki-sync/"; username = "lovelearning@email.com"; - passwordFile = testPasswordFile; + keyFile = testKeyFile; }; };