-
Notifications
You must be signed in to change notification settings - Fork 12
/
secrets.nix
34 lines (29 loc) · 1.05 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
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; {
"hardware/nixos-aarch64-builder/key.age" = [ jung riemann spinoza ];
"services/acme.age" = [ jung plato riemann ];
"services/oauth2.age" = [ jung plato riemann ];
"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"