summaryrefslogtreecommitdiff
path: root/secrets/toSecrets.nix
diff options
context:
space:
mode:
authorseth <[email protected]>2023-11-19 05:19:05 -0500
committerseth <[email protected]>2023-11-19 05:28:01 -0500
commit07a6858fd7ef6ea6794cc37323d7c9cf1162d5b6 (patch)
treea123857e27802b133b105b552b6ef48a7593bae4 /secrets/toSecrets.nix
parent2da304a66b759e8047b94a31758ffc02203e411c (diff)
secrets: reorganize & rekey
Diffstat (limited to 'secrets/toSecrets.nix')
-rw-r--r--secrets/toSecrets.nix25
1 files changed, 25 insertions, 0 deletions
diff --git a/secrets/toSecrets.nix b/secrets/toSecrets.nix
new file mode 100644
index 0000000..3d495c6
--- /dev/null
+++ b/secrets/toSecrets.nix
@@ -0,0 +1,25 @@
+hosts: let
+ optional = attrset: val:
+ if attrset ? ${val}
+ then [attrset.${val}]
+ else [];
+
+ mkPubkeys = host: optional host "pubkey" ++ optional host "owner";
+
+ op = acc: host:
+ acc
+ // (
+ builtins.listToAttrs (
+ map (
+ file: {
+ name = "${host}/${file}";
+ value = {
+ publicKeys = mkPubkeys hosts.${host};
+ };
+ }
+ )
+ hosts.${host}.files
+ )
+ );
+in
+ builtins.foldl' op {} (builtins.attrNames hosts)