summaryrefslogtreecommitdiff
path: root/util/importAll.nix
diff options
context:
space:
mode:
Diffstat (limited to 'util/importAll.nix')
-rw-r--r--util/importAll.nix15
1 files changed, 15 insertions, 0 deletions
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))