about summary refs log tree commit diff
path: root/lib/default.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2022-08-12 22:53:53 +0300
committerAzat Bahawi <azat@bahawi.net>2022-08-12 22:53:53 +0300
commit61b94f0dd06cac0f7dcd38cce80f2a7ab8376098 (patch)
treeb703a9fe11eae6c4cae4e4682f02caf0caa171d0 /lib/default.nix
2022-08-12
Diffstat (limited to '')
-rw-r--r--lib/default.nix20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
new file mode 100644
index 0000000..7a8dfbf
--- /dev/null
+++ b/lib/default.nix
@@ -0,0 +1,20 @@
+lib: _: rec {
+  my = import ./my.nix lib;
+
+  dns = import ./dns.nix lib;
+
+  isEven = number:
+    assert (builtins.isInt number) || (builtins.isFloat number);
+      builtins.div number 2 == 0;
+
+  isOdd = !isEven;
+
+  pow = base: exponent:
+    assert (builtins.isInt base) && (builtins.isInt exponent);
+    assert exponent > 0;
+      builtins.foldl' (x: _: x * base) 1 (builtins.genList _ exponent);
+
+  comcat = lib.concatStringsSep ",";
+
+  mkTcpMem = min: ini: max: (lib.concatMapStrings (x: toString x + " ") [(pow 2 min) (pow 2 ini) (pow 2 max)]);
+}

Consider giving Nix/NixOS a try! <3