lib: add mapNixDir{,1}

This commit is contained in:
tv 2018-11-30 09:40:53 +01:00
parent 53359a60f5
commit 5f0b1b8035
5 changed files with 21 additions and 29 deletions

View File

@ -15,10 +15,4 @@ let
else override;
in
listToAttrs
(map
(name: nameValuePair (removeSuffix ".nix" name)
(callPackage (./. + "/${name}") {}))
(filter
(name: name != "default.nix" && !hasPrefix "." name)
(attrNames (readDir ./.))))
mapNixDir (path: callPackage path {}) ./.

View File

@ -1,13 +1,6 @@
with import <stockholm/lib>;
let
overrides = self: super:
listToAttrs
(map
(name: nameValuePair (removeSuffix ".nix" name)
(self.callPackage (./. + "/${name}") {}))
(filter
(name: name != "default.nix" && !hasPrefix "." name)
(attrNames (readDir ./.))));
overrides = self: super: mapNixDir (path: self.callPackage path {}) ./.;
in
self: super:
{

View File

@ -15,10 +15,4 @@ let
else override;
in
listToAttrs
(map
(name: nameValuePair (removeSuffix ".nix" name)
(callPackage (./. + "/${name}") {}))
(filter
(name: name != "default.nix" && !hasPrefix "." name)
(attrNames (readDir ./.))))
mapNixDir (path: callPackage path {}) ./.

View File

@ -44,6 +44,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

View File

@ -15,10 +15,4 @@ let
else override;
in
listToAttrs
(map
(name: nameValuePair (removeSuffix ".nix" name)
(callPackage (./. + "/${name}") {}))
(filter
(name: name != "default.nix" && !hasPrefix "." name)
(attrNames (readDir ./.))))
mapNixDir (path: callPackage path {}) ./.