about summary refs log tree commit diff
path: root/secrets.nix
diff options
context:
space:
mode:
authorEmile <git@emile.space>2024-09-19 10:48:16 +0200
committerEmile <git@emile.space>2024-09-19 10:48:16 +0200
commite833c13c177288b2a7b9168a784e0e6562c025b6 (patch)
tree1661dad1694989e2d83e6c2fca7b5602a61c574b /secrets.nix
parentdcde3882d5460368e3c0499a54330f84a6995d62 (diff)
big format using nixfmt
Diffstat (limited to 'secrets.nix')
-rw-r--r--secrets.nix94
1 files changed, 48 insertions, 46 deletions
diff --git a/secrets.nix b/secrets.nix
index 67bf9b9..8ad8eb7 100644
--- a/secrets.nix
+++ b/secrets.nix
@@ -12,54 +12,56 @@
 # and renamed afterwards
 
 let
-	pubkeysFor = directory:
-		let
-			instances = builtins.attrNames (builtins.readDir directory);
-			instancesWithPubkey = builtins.filter (i: builtins.pathExists (directory + "/${i}/ssh.pub")) instances; 
-		in
-			builtins.listToAttrs (
-				# map (i: { name = i; value = builtins.readFile (directory + "/${i}/ssh.pub"); }
-				map (i: {
-					name = i;
-					value = (import (directory + "/${i}/")).sshKey;
-				}
-			) instancesWithPubkey);
+  pubkeysFor =
+    directory:
+    let
+      instances = builtins.attrNames (builtins.readDir directory);
+      instancesWithPubkey = builtins.filter (
+        i: builtins.pathExists (directory + "/${i}/ssh.pub")
+      ) instances;
+    in
+    builtins.listToAttrs (
+      # map (i: { name = i; value = builtins.readFile (directory + "/${i}/ssh.pub"); }
+      map (i: {
+        name = i;
+        value = (import (directory + "/${i}/")).sshKey;
+      }) instancesWithPubkey
+    );
 
-	hosts = pubkeysFor ./nix/hosts;
-	users = pubkeysFor ./nix/users;
+  hosts = pubkeysFor ./nix/hosts;
+  users = pubkeysFor ./nix/users;
 
-	secretsForHost = hostname: let
+  secretsForHost =
+    hostname:
+    let
 
-		secretFiles = builtins.attrNames
-			(builtins.readDir (./nix/hosts + "/${hostname}/secrets"));
-	
-		listOfSecrets = builtins.filter (i:
-			(builtins.stringLength i) > 4
-			&& builtins.substring ((builtins.stringLength i) - 4)
-				(builtins.stringLength i) i == ".age"
-		) secretFiles;
+      secretFiles = builtins.attrNames (builtins.readDir (./nix/hosts + "/${hostname}/secrets"));
 
-	in
-		if
-			builtins.pathExists (./nix/hosts + "/${hostname}/secrets")
-			&& builtins.pathExists (./nix/hosts + "/${hostname}/ssh.pub")
-		then
-			map
-				(secret: {
-					name = "nix/hosts/${hostname}/secrets/${secret}";
-					value = {
-						publicKeys = [
-							users.emile
-							hosts."${hostname}"
-						];
-					};
-				})
-				(listOfSecrets ++ [ "new" ])
-		else
-			[];
+      listOfSecrets = builtins.filter (
+        i:
+        (builtins.stringLength i) > 4
+        && builtins.substring ((builtins.stringLength i) - 4) (builtins.stringLength i) i == ".age"
+      ) secretFiles;
+
+    in
+    if
+      builtins.pathExists (./nix/hosts + "/${hostname}/secrets")
+      && builtins.pathExists (./nix/hosts + "/${hostname}/ssh.pub")
+    then
+      map (secret: {
+        name = "nix/hosts/${hostname}/secrets/${secret}";
+        value = {
+          publicKeys = [
+            users.emile
+            hosts."${hostname}"
+          ];
+        };
+      }) (listOfSecrets ++ [ "new" ])
+    else
+      [ ];
 in
-	builtins.listToAttrs (
-		builtins.concatMap
-			(hostname: secretsForHost hostname)
-			(builtins.attrNames (builtins.readDir ./nix/hosts))
-	)
+builtins.listToAttrs (
+  builtins.concatMap (hostname: secretsForHost hostname) (
+    builtins.attrNames (builtins.readDir ./nix/hosts)
+  )
+)