Modules/Sops: Allow setting secrets with "neededForUsers = true;"
This commit is contained in:
@ -14,7 +14,7 @@ in {
|
|||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
sops
|
sops
|
||||||
age
|
age
|
||||||
ssh-to-age
|
# ssh-to-age
|
||||||
];
|
];
|
||||||
|
|
||||||
environment.variables = {
|
environment.variables = {
|
||||||
@ -32,11 +32,33 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
secrets = let
|
secrets = let
|
||||||
mkSecret = name: {${name} = {};};
|
mkSecret = name: {
|
||||||
|
${name} = {
|
||||||
|
owner = config.users.users.${username}.name;
|
||||||
|
group = config.users.users.${username}.group;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkBootSecret = name: {
|
||||||
|
${name} = {
|
||||||
|
# Make these secrets available before creating users.
|
||||||
|
# This means we can't set the owner or group.
|
||||||
|
neededForUsers = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
|
lib.mkMerge [
|
||||||
|
(
|
||||||
if (builtins.hasAttr "${username}" sops-nix.secrets)
|
if (builtins.hasAttr "${username}" sops-nix.secrets)
|
||||||
then lib.mergeAttrsList (builtins.map mkSecret sops-nix.secrets.${username})
|
then lib.mergeAttrsList (builtins.map mkSecret sops-nix.secrets.${username})
|
||||||
else {};
|
else {}
|
||||||
|
)
|
||||||
|
(
|
||||||
|
if (builtins.hasAttr "${username}" sops-nix.bootSecrets)
|
||||||
|
then lib.mergeAttrsList (builtins.map mkBootSecret sops-nix.bootSecrets.${username})
|
||||||
|
else {}
|
||||||
|
)
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,15 @@
|
|||||||
'';
|
'';
|
||||||
default = [];
|
default = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bootSecrets = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf (lib.types.listOf lib.types.str);
|
||||||
|
description = "The secrets to expose on this host earlier in the boot process";
|
||||||
|
example = ''
|
||||||
|
christoph = [
|
||||||
|
"user-password"
|
||||||
|
];
|
||||||
|
'';
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user