diff --git a/home/hosts/andromache/default.nix b/home/hosts/andromache/default.nix index 697fed5f..fce04dfb 100644 --- a/home/hosts/andromache/default.nix +++ b/home/hosts/andromache/default.nix @@ -63,6 +63,7 @@ bash.addBinToPath = true; }; anki.enable = true; + anki.enable = true; k8s.k9s.enable = true; taskwarrior.enable = true; audio.enable = true; diff --git a/home/hosts/work/default.nix b/home/hosts/work/default.nix index a1152e3d..1e0cef18 100644 --- a/home/hosts/work/default.nix +++ b/home/hosts/work/default.nix @@ -89,6 +89,7 @@ postgresql.enable = true; redis.enable = true; }; + anki.enable = true; k8s.enable = true; shell.enable = true; my.stylix.enable = true; diff --git a/home/modules/anki/default.nix b/home/modules/anki/default.nix index 6d0429f4..5ea05fd3 100644 --- a/home/modules/anki/default.nix +++ b/home/modules/anki/default.nix @@ -9,33 +9,40 @@ }: let + cfg = config.anki; sops = myUtils.sopsAvailability config osConfig; standalone = osConfig == null; in -lib.optionalAttrs standalone { - sops.secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" null { - anki = [ - "sync-user" - "sync-key" - ]; - }; -} -// { - warnings = lib.optional ( - !sops.available && config.programs.anki.enable - ) "anki is enabled but sops secrets are not available. anki sync will not be configured."; +{ + options.anki.enable = lib.mkEnableOption "Anki"; - programs.anki = { - enable = true; - package = config.nixgl.wrap pkgs.anki; - addons = with pkgs.ankiAddons; [ - anki-connect - puppy-reinforcement - review-heatmap - ]; - profiles."User 1".sync = lib.mkIf sops.available { - usernameFile = "${sops.secrets."anki/sync-user".path}"; - keyFile = "${sops.secrets."anki/sync-key".path}"; - }; - }; + config = lib.mkIf cfg.enable ( + lib.optionalAttrs standalone { + sops.secrets = myUtils.mkSopsSecrets "${toString inputs.nix-secrets}/secrets" null { + anki = [ + "sync-user" + "sync-key" + ]; + }; + } + // { + warnings = lib.optional ( + !sops.available + ) "anki is enabled but sops secrets are not available. anki sync will not be configured."; + + programs.anki = { + enable = true; + package = config.nixgl.wrap pkgs.anki; + addons = with pkgs.ankiAddons; [ + anki-connect + puppy-reinforcement + review-heatmap + ]; + profiles."User 1".sync = lib.mkIf sops.available { + usernameFile = "${sops.secrets."anki/sync-user".path}"; + keyFile = "${sops.secrets."anki/sync-key".path}"; + }; + }; + } + ); } diff --git a/modules/anki/default.nix b/modules/anki/default.nix index 3700afa8..46f2b191 100644 --- a/modules/anki/default.nix +++ b/modules/anki/default.nix @@ -1,6 +1,15 @@ +{ lib, config, ... }: + +let + cfg = config.anki; +in { - config.secrets.groups.anki = [ - "sync-user" - "sync-key" - ]; + options.anki.enable = lib.mkEnableOption "anki"; + + config = lib.mkIf cfg.enable { + secrets.groups.anki = [ + "sync-user" + "sync-key" + ]; + }; }