-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsecrets.nix
52 lines (47 loc) · 1.06 KB
/
secrets.nix
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
47
48
49
50
51
52
let
inherit (builtins)
attrNames
attrValues
filter
mapAttrs
listToAttrs
;
bemeurer = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIQgTWfmR/Z4Szahx/uahdPqvEP/e/KQ1dKUYLenLuY2";
hosts =
let
all = import ./nix/hosts.nix;
withPubkey = filter (a: all.${a} ? pubkey) (attrNames all);
in
listToAttrs (
map (name: {
inherit name;
value = all.${name}.pubkey;
}) withPubkey
);
secrets = with hosts; {
"services/acme.age" = [
jung
plato
];
"services/oauth2.age" = [
jung
plato
];
"services/pihole.age" = [ ];
"services/github-runner.age" = [ jung ];
"users/bemeurer/password.age" = attrValues hosts;
};
secrets' = mapAttrs (_: v: { publicKeys = [ bemeurer ] ++ v; }) secrets;
allHostSecret =
secretName:
listToAttrs (
map (host: {
name = "hosts/${host}/${secretName}.age";
value.publicKeys = [
bemeurer
hosts.${host}
];
}) (attrNames hosts)
);
in
secrets' // allHostSecret "password"