vars: allow setting files as needed for activation

This commit is contained in:
lassulus
2024-12-18 15:09:20 +01:00
parent 37dc74d0f7
commit d91f653a65
9 changed files with 50 additions and 16 deletions

View File

@@ -27,8 +27,11 @@ in
# Before we generate a secret we cannot know the path yet, so we need to set it to an empty string
fileModule = file: {
path = lib.mkIf file.config.secret (
config.sops.secrets.${"vars/${file.config.generatorName}/${file.config.name}"}.path
or "/no-such-path"
if file.config.neededFor == "activation" then
"/var/lib/sops-nix/${file.config.generatorName}/${file.config.name}"
else
config.sops.secrets.${"vars/${file.config.generatorName}/${file.config.name}"}.path
or "/no-such-path"
);
};
secretModule = "clan_cli.vars.secret_modules.sops";

View File

@@ -16,7 +16,9 @@ in
collectFiles =
vars:
let
relevantFiles = generator: flip filterAttrs generator.files (_name: f: f.secret && f.deploy);
relevantFiles =
generator:
flip filterAttrs generator.files (_name: f: f.secret && f.deploy && (f.neededFor != "activation"));
allFiles = flatten (
flip mapAttrsToList vars.generators (
gen_name: generator:
@@ -24,8 +26,9 @@ in
fname: file: {
name = fname;
generator = gen_name;
neededForUsers = file.neededFor == "users";
inherit (generator) share;
inherit (file) owner group neededForUsers;
inherit (file) owner group;
}
)
)