blob: 9e0e025ccf5f49518d5ee06f4d78428c1d87faa3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
{
config,
lib,
inputs,
secretsDir,
...
}:
let
cfg = config.traits.secrets;
in
{
options.traits.secrets = {
enable = lib.mkEnableOption "secrets management";
hostUser = lib.mkEnableOption "manager secrets for host user (see `profiles.server.hostUser`)" // {
default = config.profiles.server.hostUser;
defaultText = "config.profiles.server.hostUser";
};
};
imports = [ inputs.agenix.nixosModules.default ];
config = lib.mkIf cfg.enable (
lib.mkMerge [
{
_module.args = {
secretsDir = inputs.self + "/secrets/${config.networking.hostName}";
};
age = {
identityPaths = [ "/etc/age/key" ];
};
}
(lib.mkIf (config.profiles.server.enable && cfg.hostUser) {
age.secrets = {
userPassword.file = secretsDir + "/userPassword.age";
};
users.users.${config.networking.hostName} = {
hashedPasswordFile = config.age.secrets.userPassword.path;
};
})
]
);
}
|