Commit 0423fa757403

Vincent Demeester <vincent@sbr.pm>
2025-05-09 23:35:45
globals: document some functions
Ideally, we should move them elsewhere ? Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent cef54d6
Changed files (1)
globals.nix
@@ -39,7 +39,22 @@
   };
   # FIXME Maybe I should move this elsewhere, in ./lib maybe ?
   fn = {
+    /**
+         Return a list of wireguard ips from a list of ips.
+
+         Essentially, it will append /24 to the each element of the list.
+      *
+    */
     wg-ips = ips: builtins.map (x: "${x}/24") ips;
-    hasSyncthingFolders = host: (builtins.length (lib.attrsets.attrValues host.syncthing.folders)) > 0;
+
+    /**
+        Return true if the given host has a list of Syncthing folder configured.
+      *
+    */
+    hasSyncthingFolders =
+      host:
+      builtins.hasAttr "syncthing" host
+      && builtins.hasAttr "folders" host.syncthing
+      && (builtins.length (lib.attrsets.attrValues host.syncthing.folders)) > 0;
   };
 }