diff options
author | jeschli <jeschli@gmail.com> | 2018-12-04 19:27:27 +0100 |
---|---|---|
committer | jeschli <jeschli@gmail.com> | 2018-12-04 19:27:27 +0100 |
commit | 5030b74cc5c578bb82619a24592504a6008f1a10 (patch) | |
tree | 0551e3ddb94353b7438bec02174bf3379bc89b87 /lib | |
parent | 78b289201987675844aa37abeb4279eb4051ebe0 (diff) | |
parent | 82988de84c177c247ebbe80940c4d50b9f073b4e (diff) |
Merge branch 'master' of prism.r:stockholm
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; }; }; }); |