diff options
Diffstat (limited to '')
| -rw-r--r-- | util/default.nix | 3 | ||||
| -rw-r--r-- | util/importAll.nix | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/util/default.nix b/util/default.nix new file mode 100644 index 0000000..226c69f --- /dev/null +++ b/util/default.nix @@ -0,0 +1,3 @@ +lib: { + importAll = import ./importAll.nix lib; +} diff --git a/util/importAll.nix b/util/importAll.nix new file mode 100644 index 0000000..c4a092e --- /dev/null +++ b/util/importAll.nix @@ -0,0 +1,15 @@ +lib: +{ root, exclude ? [] }: +with builtins; with lib; + +# http://chriswarbo.net/projects/nixos/useful_hacks.html +let + isMatch = name: type: (hasSuffix ".nix" name || type == "directory") + && ! elem name exclude; + + entry = name: _: { + name = removeSuffix ".nix" name; + value = import (root + "/${name}"); + }; +in + mapAttrs' entry (filterAttrs isMatch (readDir root)) |
