default.nix (905B)
1 { lib, ... }: 2 3 with lib; 4 5 let 6 importModulesRecursively = dir: 7 let d = builtins.readDir dir; in 8 if hasAttrByPath [ "default.nix" ] d then [ "" ] else 9 concatLists (mapAttrsToList 10 (n: v: 11 if v == "directory" then 12 map (f: "${n}/${f}") (importModulesRecursively "${toString dir}/${n}") 13 else [ "${n}" ]) 14 d); 15 16 callImportModules = dir: 17 let d = builtins.readDir dir; in 18 concatLists (mapAttrsToList 19 (n: v: 20 if v == "directory" then 21 map (f: "${toString dir}/${n}/${f}") (importModulesRecursively "${toString dir}/${n}") 22 else "${toString dir}/${n}") 23 (filterAttrs (n: v: n != "default.nix") d)); 24 in 25 { 26 # Basically just imports everything 27 # If importing a directory which contains a default.nix treat it like 28 # it is its own module 29 # An example of one of these is ./dev/neovim 30 imports = callImportModules ./.; 31 }