From e6ed60548397627bf10f561f9438201dbba0a36e Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Sun, 21 Apr 2024 02:15:42 +0300 Subject: 2024-04-21 --- lib/default.nix | 48 +++++++++++++++++++++++++++++++++--------------- lib/my.nix | 22 ---------------------- 2 files changed, 33 insertions(+), 37 deletions(-) (limited to 'lib') diff --git a/lib/default.nix b/lib/default.nix index ab4ca0d..cd4b601 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,4 +1,4 @@ -lib: _: rec { +lib: _: with lib; rec { my = import ./my.nix lib; dns = import ./dns.nix; @@ -8,7 +8,7 @@ lib: _: rec { assert (builtins.isInt number) || (builtins.isFloat number); builtins.div number 2 == 0; - isOdd = !isEven; + isOdd = number: !isEven number; pow = base: exponent: @@ -16,19 +16,10 @@ lib: _: rec { assert exponent > 0; 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; - value = f name; - }) attrs - ); - mkTcpMem = min: ini: max: assert min <= ini && ini <= max; - lib.concatMapStrings (x: toString x + " ") ( + concatMapStrings (x: toString x + " ") ( map (pow 2) [ min ini @@ -36,6 +27,33 @@ lib: _: rec { ] ); + modulesIn = + dir: + pipe dir [ + builtins.readDir + (mapAttrsToList ( + name: type: + if type == "regular" && hasSuffix ".nix" name && name != "default.nix" then + [ + { + name = removeSuffix ".nix" name; + value = dir + "/${name}"; + } + ] + else if type == "directory" && pathExists (dir + "/${name}/default.nix") then + [ + { + inherit name; + value = dir + "/${name}"; + } + ] + else + [ ] + )) + concatLists + listToAttrs + ]; + moduleFromRef = module: ref: sha256: { disabledModules = [ module ]; imports = [ @@ -44,9 +62,9 @@ lib: _: rec { src = builtins.fetchTarball { url = let - cons = lib.splitString ":" ref; - owner = lib.head cons; - branch = lib.last cons; + cons = splitString ":" ref; + owner = head cons; + branch = last cons; in "https://github.com/${owner}/nixpkgs/archive/refs/heads/${branch}.tar.gz"; inherit sha256; diff --git a/lib/my.nix b/lib/my.nix index 391d0ee..c0ec35a 100644 --- a/lib/my.nix +++ b/lib/my.nix @@ -258,28 +258,6 @@ with lib; syncthing.id = "@SYNCTHING_ID@"; }; - # Macbook Air M1. - mairon = { - system = "aarch64-darwin"; - isHeadful = true; - wireguard = { - ipv4.address = "10.69.4.2"; - ipv6.address = "fd69::4:2"; - publicKey = "@PUBLIC_KEY@"; - }; - }; - - # Google Pixel 4a w/ GrapheneOS. - gothmog = { - isOther = true; - wireguard = { - ipv4.address = "10.69.5.1"; - ipv6.address = "fd69::5:1"; - publicKey = "@PUBLIC_KEY@"; - }; - syncthing.id = "@SYNCTHING_ID@"; - }; - # Google Pixel 7a w/ GrapheneOS. lungorthin = { isOther = true; -- cgit v1.2.3