summaryrefslogtreecommitdiff
path: root/doctrine/lib/import-all.nix
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2025-08-06 14:05:49 -0600
committerAlejandro Soto <alejandro@34project.org>2025-08-06 14:36:55 -0600
commitccfca16452e91705330abc09cea1f9dd897c00f7 (patch)
tree495bfd35153d707eb835c3cc059df5144bc66c81 /doctrine/lib/import-all.nix
parentf2bffec80259b1a7902bd91166f4982edc9dc363 (diff)
doctrine/lib: rename importAll.nix -> import-all.nix
Diffstat (limited to 'doctrine/lib/import-all.nix')
-rw-r--r--doctrine/lib/import-all.nix21
1 files changed, 21 insertions, 0 deletions
diff --git a/doctrine/lib/import-all.nix b/doctrine/lib/import-all.nix
new file mode 100644
index 0000000..423dd9c
--- /dev/null
+++ b/doctrine/lib/import-all.nix
@@ -0,0 +1,21 @@
+{
+ lib,
+ root,
+ exclude ? ["default"],
+}:
+with builtins;
+with lib;
+# http://chriswarbo.net/projects/nixos/useful_hacks.html
+ let
+ basename = removeSuffix ".nix";
+
+ isMatch = name: type:
+ (hasSuffix ".nix" name || type == "directory")
+ && ! elem (basename name) exclude;
+
+ entry = name: _: {
+ name = basename name;
+ value = import (root + "/${name}");
+ };
+ in
+ mapAttrs' entry (filterAttrs isMatch (readDir root))