Skip to content

Commit e2b719e

Browse files
MartinNikovPetarKirov
authored andcommitted
config(modules/secrets): Add extraKeys per host
1 parent ce95398 commit e2b719e

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

modules/secrets.nix

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
eachServiceCfg = config.mcl.secrets.services;
1313
isDebugVM = config.mcl.host-info.isDebugVM;
1414

15+
mcl-secrets = config.mcl.secrets;
16+
1517
sshKey =
1618
if isDebugVM then
1719
config.virtualisation.vmVariant.mcl.host-info.sshKey
@@ -36,6 +38,16 @@
3638
];
3739

3840
options.mcl.secrets = with lib; {
41+
extraKeys = mkOption {
42+
type = types.listOf types.str;
43+
default = [ ];
44+
example = [
45+
"ssh-ed25519 AAAAC3Nza"
46+
"ssh-ed25519 AAAACSNss"
47+
];
48+
description = "Extra keys which can decrypt the secrets.";
49+
};
50+
3951
services = mkOption {
4052
type = types.attrsOf (
4153
types.submodule (
@@ -84,11 +96,12 @@
8496
default = builtins.toFile "${serviceName}-secrets.nix" ''
8597
let
8698
hostKey = ["${sshKey}"];
87-
extraKeys = ["${concatStringsSep "\"\"" config.extraKeys}"];
99+
extraKeysPerService = ["${concatStringsSep "\"\"" config.extraKeys}"];
100+
extraKeysPerHost = ["${concatStringsSep "\"\"" mcl-secrets.extraKeys}"];
88101
in {
89-
${concatMapStringsSep "\n" (n: "\"${n}.age\".publicKeys = hostKey ++ extraKeys;") (
90-
builtins.attrNames config.secrets
91-
)}
102+
${concatMapStringsSep "\n" (
103+
n: "\"${n}.age\".publicKeys = hostKey ++ extraKeysPerService ++ extraKeysPerHost;"
104+
) (builtins.attrNames config.secrets)}
92105
}
93106
'';
94107
type = types.path;

0 commit comments

Comments
 (0)