diff options
author | makefu <github@syntax-fehler.de> | 2018-12-05 16:41:38 +0100 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2018-12-05 16:41:38 +0100 |
commit | a4556a17f6639efe13e709bf53af15bb2a70c82d (patch) | |
tree | c81f829077d32fce39baaf7bfa526d8cac071879 /lib | |
parent | 1859d6653a12e1bfda9465780610f63da8f5ce69 (diff) | |
parent | e4750d38e76db94a0b255fa143408b8cbe38b61b (diff) |
Merge remote-tracking branch 'lass/master' into HEAD
Diffstat (limited to 'lib')
-rw-r--r-- | lib/default.nix | 23 | ||||
-rw-r--r-- | lib/types.nix | 6 |
2 files changed, 24 insertions, 5 deletions
diff --git a/lib/default.nix b/lib/default.nix index a40225c49..348d47e85 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -5,6 +5,7 @@ let evalSource = import ./eval-source.nix; git = import ./git.nix { inherit lib; }; + krops = import ../submodules/krops/lib; shell = import ./shell.nix { inherit lib; }; types = nixpkgs-lib.types // import ./types.nix { inherit lib; }; @@ -12,8 +13,9 @@ let ne = x: y: x != y; mod = x: y: x - y * (x / y); - genid = import ./genid.nix { inherit lib; }; - genid_uint31 = x: ((lib.genid x) + 16777216) / 2; + genid = lib.genid_uint32; # TODO remove + genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2; + genid_uint32 = import ./genid.nix { inherit lib; }; lpad = n: c: s: if lib.stringLength s < n @@ -44,6 +46,23 @@ let indent = replaceChars ["\n"] ["\n "]; + mapNixDir = f: x: { + list = foldl' mergeAttrs {} (map (mapNixDir1 f) x); + path = mapNixDir1 f x; + }.${typeOf x}; + + mapNixDir1 = f: dirPath: + listToAttrs + (map + (relPath: let + name = removeSuffix ".nix" relPath; + path = dirPath + "/${relPath}"; + in + nameValuePair name (f path)) + (filter + (name: name != "default.nix" && !hasPrefix "." name) + (attrNames (readDir dirPath)))); + # https://tools.ietf.org/html/rfc5952 normalize-ip6-addr = let diff --git a/lib/types.nix b/lib/types.nix index d663d2512..016853300 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -3,7 +3,7 @@ let inherit (lib) all any attrNames concatMapStringsSep concatStringsSep const filter flip - genid hasSuffix head isInt isString length mergeOneOption mkOption + genid_uint31 hasSuffix head isInt isString length mergeOneOption mkOption mkOptionType optional optionalAttrs optionals range splitString stringLength substring test testString typeOf; inherit (lib.types) @@ -365,7 +365,7 @@ rec { }; uid = mkOption { type = int; - default = genid config.name; + default = genid_uint31 config.name; }; }; }); @@ -377,7 +377,7 @@ rec { }; gid = mkOption { type = int; - default = genid config.name; + default = genid_uint31 config.name; }; }; }); |