From 59180328cda59817d71cd58c8f48ead047375064 Mon Sep 17 00:00:00 2001 From: azahi Date: Mon, 17 Feb 2025 02:21:56 +0300 Subject: 2025-02-17 --- lib/default.nix | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'lib/default.nix') diff --git a/lib/default.nix b/lib/default.nix index e06b7ec..fbb6086 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -4,7 +4,7 @@ system, ... }: -rec { +{ my = import ./my.nix { inherit lib inputs system; }; dns = import ./dns.nix { inherit lib inputs system; }; @@ -18,7 +18,7 @@ rec { assert (builtins.isInt number) || (builtins.isFloat number); builtins.div number 2 == 0; - isOdd = number: !isEven number; + isOdd = number: !lib.isEven number; pow = base: exponent: @@ -29,20 +29,21 @@ rec { mkTcpMem = min: ini: max: assert min <= ini && ini <= max; - lib.concatMapStrings (x: toString x + " ") ( - map (pow 2) [ - min - ini - max - ] - ); + [ + min + ini + max + ] + |> map (lib.pow 2) + |> map toString + |> lib.concatStringsSep " "; # Load all files from directory (partially recursively). # # Usage: Assuming other Nix files are present in a directory: # ``` # { ... }: { - # imports = attrValue (modulesIn ./.); + # imports = modulesIn ./. |> attrValues; # # services.foobar.enable = true; # } @@ -50,23 +51,22 @@ rec { # modulesIn = dir: - lib.pipe dir [ - builtins.readDir - (lib.mapAttrsToList ( - name: type: - let - modulePath = dir + "/${name}"; - in - if type == "regular" && lib.hasSuffix ".nix" name && name != "default.nix" then - [ (lib.nameValuePair (lib.removeSuffix ".nix" name) modulePath) ] - else if type == "directory" && lib.pathExists (modulePath + "/default.nix") then - [ (lib.nameValuePair name modulePath) ] - else - [ ] - )) - lib.concatLists - lib.listToAttrs - ]; + dir + |> builtins.readDir + |> (lib.mapAttrsToList ( + name: type: + let + modulePath = dir + "/${name}"; + in + if type == "regular" && lib.hasSuffix ".nix" name && name != "default.nix" then + [ (lib.nameValuePair (lib.removeSuffix ".nix" name) modulePath) ] + else if type == "directory" && lib.pathExists (modulePath + "/default.nix") then + [ (lib.nameValuePair name modulePath) ] + else + [ ] + )) + |> lib.concatLists + |> lib.listToAttrs; # Override a module using another Nixpkgs source tree. # -- cgit 1.4.1