trivionomicon/doctrine/lib/import-all.nix
2025-08-06 14:36:55 -06:00

22 lines
453 B
Nix

{
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))