diff options
| author | Alejandro Soto <alejandro@34project.org> | 2024-08-02 14:25:52 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2024-08-02 17:10:10 -0600 |
| commit | d16bcb693db18b8ab2508cef6400ce1219dac833 (patch) | |
| tree | c031207e7f1784fe1e913d35436c02e63f79f814 /pkgs/lib/importAll.nix | |
| parent | 951025ec921a83d9ade36252b2fdc6da9f469c03 (diff) | |
pkgs/lib: refactor out of util/
Diffstat (limited to 'pkgs/lib/importAll.nix')
| -rw-r--r-- | pkgs/lib/importAll.nix | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/pkgs/lib/importAll.nix b/pkgs/lib/importAll.nix new file mode 100644 index 0000000..30a1dd9 --- /dev/null +++ b/pkgs/lib/importAll.nix @@ -0,0 +1,17 @@ +{ lib }: +{ root, exclude ? [ ] }: +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 name (map basename exclude); + + entry = name: _: { + name = basename name; + value = import (root + "/${name}"); + }; +in +mapAttrs' entry (filterAttrs isMatch (readDir root)) |
