about summary refs log tree commit diff
path: root/lib/default.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/default.nix63
1 files changed, 38 insertions, 25 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 7fbaeec..ab4ca0d 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -3,44 +3,57 @@ lib: _: rec {
 
   dns = import ./dns.nix;
 
-  isEven = number:
+  isEven =
+    number:
     assert (builtins.isInt number) || (builtins.isFloat number);
-      builtins.div number 2 == 0;
+    builtins.div number 2 == 0;
 
   isOdd = !isEven;
 
-  pow = base: exponent:
+  pow =
+    base: exponent:
     assert (builtins.isInt base) && (builtins.isInt exponent);
     assert exponent > 0;
-      builtins.foldl' (x: _: x * base) 1 (builtins.genList (_: _) exponent);
+    builtins.foldl' (x: _: x * base) 1 (builtins.genList (_: _) exponent);
 
-  mapListToAttrs = f: attrs:
-    builtins.listToAttrs (map (name: {
-        name =
-          if builtins.isList name
-          then builtins.elemAt name (builtins.length name - 1)
-          else name;
+  mapListToAttrs =
+    f: attrs:
+    builtins.listToAttrs (
+      map (name: {
+        name = if builtins.isList name then builtins.elemAt name (builtins.length name - 1) else name;
         value = f name;
-      })
-      attrs);
+      }) attrs
+    );
 
-  mkTcpMem = min: ini: max:
+  mkTcpMem =
+    min: ini: max:
     assert min <= ini && ini <= max;
-      lib.concatMapStrings (x: toString x + " ") (map (pow 2) [min ini max]);
+    lib.concatMapStrings (x: toString x + " ") (
+      map (pow 2) [
+        min
+        ini
+        max
+      ]
+    );
 
   moduleFromRef = module: ref: sha256: {
-    disabledModules = [module];
+    disabledModules = [ module ];
     imports = [
-      (let
-        src = builtins.fetchTarball {
-          url = let
-            cons = lib.splitString ":" ref;
-            owner = lib.head cons;
-            branch = lib.last cons;
-          in "https://github.com/${owner}/nixpkgs/archive/refs/heads/${branch}.tar.gz";
-          inherit sha256;
-        };
-      in "${src}/nixos/modules/${module}")
+      (
+        let
+          src = builtins.fetchTarball {
+            url =
+              let
+                cons = lib.splitString ":" ref;
+                owner = lib.head cons;
+                branch = lib.last cons;
+              in
+              "https://github.com/${owner}/nixpkgs/archive/refs/heads/${branch}.tar.gz";
+            inherit sha256;
+          };
+        in
+        "${src}/nixos/modules/${module}"
+      )
     ];
   };
 }

Consider giving Nix/NixOS a try! <3