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