refactor: adopt modular secrets approach

This commit is contained in:
2026-03-13 23:03:59 +01:00
committed by hektor
parent 3f9c9cd154
commit 916e732ce6
14 changed files with 212 additions and 161 deletions

View File

@@ -2,20 +2,17 @@
config,
lib,
pkgs,
myUtils,
osConfig ? null,
...
}:
let
hmSopsAvailable = config ? sops && config.sops ? secrets;
osSopsAvailable = osConfig != null && osConfig ? sops && osConfig.sops ? secrets;
sopsAvailable = hmSopsAvailable || osSopsAvailable;
sopsSecrets = if hmSopsAvailable then config.sops.secrets else osConfig.sops.secrets;
sops = myUtils.sopsAvailability config osConfig;
in
{
warnings = lib.optional (
!sopsAvailable && config.programs.anki.enable
!sops.available && config.programs.anki.enable
) "anki is enabled but sops secrets are not available. anki sync will not be configured.";
programs.anki = {
@@ -26,9 +23,9 @@ in
puppy-reinforcement
review-heatmap
];
profiles."User 1".sync = lib.mkIf sopsAvailable {
usernameFile = "${sopsSecrets."anki_sync_user".path}";
keyFile = "${sopsSecrets."anki_sync_key".path}";
profiles."User 1".sync = lib.mkIf sops.available {
usernameFile = "${sops.secrets."anki-sync-user".path}";
keyFile = "${sops.secrets."anki-sync-key".path}";
};
};
}

View File

@@ -14,8 +14,7 @@ in
warnings =
lib.optional (!isNixOS)
"hcloud module requires NixOS host configuration. This module will not work with standalone home-manager.";
home = {
packages = with pkgs; [ hcloud ];
};
home.packages = with pkgs; [ hcloud ];
};
}

View File

@@ -3,20 +3,17 @@
lib,
pkgs,
dotsPath,
myUtils,
osConfig ? null,
...
}:
let
hmSopsAvailable = config ? sops && config.sops ? templates;
osSopsAvailable = osConfig != null && osConfig ? sops && osConfig.sops ? templates;
sopsAvailable = hmSopsAvailable || osSopsAvailable;
sopsTemplates = if hmSopsAvailable then config.sops.templates else osConfig.sops.templates;
sops = myUtils.sopsAvailability config osConfig;
in
{
warnings =
lib.optional (!sopsAvailable && config.programs.taskwarrior.enable)
lib.optional (!sops.available && config.programs.taskwarrior.enable)
"taskwarrior is enabled, but sops templates are not available. taskwarrior sync will not be configured.";
home.packages = with pkgs; [
@@ -27,7 +24,7 @@ in
home.file = {
".config/task/taskrc" = {
force = true; # overwrite when present
force = true;
source = dotsPath + "/.config/task/taskrc";
};
".config/task/taskrc.d/aliases".source = dotsPath + "/.config/task/taskrc.d/aliases";
@@ -60,8 +57,8 @@ in
config = {
recurrence = "off";
};
extraConfig = lib.optionalString sopsAvailable ''
include ${sopsTemplates."taskrc.d/sync".path}
extraConfig = lib.optionalString sops.available ''
include ${sops.templates."taskrc.d/sync".path}
'';
};
}