Files
nix/home/modules/anki/default.nix
T
2026-11-06 16:43:26 +01:00

53 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
cfg = config.anki;
syncReady = config.secrets.path ? "anki/sync-user" && config.secrets.path ? "anki/sync-key";
in
{
options.anki.enable = lib.mkEnableOption "Anki";
config = lib.mkIf cfg.enable {
secrets.files.anki = [
"sync-user"
"sync-key"
];
warnings = lib.optional (
!syncReady
) "anki is enabled but its secrets are unavailable. anki sync will not be configured.";
programs.anki = {
enable = true;
package = config.nixgl.wrap pkgs.anki;
addons = with pkgs.ankiAddons; [
(anki-connect.withConfig {
# https://git.sr.ht/~foosoft/anki-connect/tree/master/item/plugin/config.json
config = {
apiKey = null;
apiLogPath = null;
webBindAddress = "127.0.0.1";
webBindPort = 8765;
webCorsOriginList = [ "http://localhost" ];
ignoreOriginList = [ ];
};
})
puppy-reinforcement
review-heatmap
];
profiles."User 1".sync = lib.mkIf syncReady {
usernameFile = config.secrets.path."anki/sync-user";
keyFile = config.secrets.path."anki/sync-key";
};
};
# allow Anki to write prefs
home.file."${config.xdg.dataHome}/Anki2/prefs21.db".enable = lib.mkForce false;
};
}