diff --git a/home/david/modules/programs/default.nix b/home/david/modules/programs/default.nix deleted file mode 100644 index 1f8bd9e..0000000 --- a/home/david/modules/programs/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -{lib, ...}: { - imports = lib.youthlic.loadImports ./.; -} diff --git a/home/modules/programs/default.nix b/home/modules/programs/default.nix deleted file mode 100644 index 1f8bd9e..0000000 --- a/home/modules/programs/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -{lib, ...}: { - imports = lib.youthlic.loadImports ./.; -} diff --git a/lib/default.nix b/lib/default.nix index c62e543..6ff08e0 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,17 +1,35 @@ final: _prev: { youthlic = { loadImports' = dir: f: - if (builtins.pathExists dir && (builtins.readFileType dir) == "directory") - then - with final; - pipe dir [ - builtins.readDir - attrNames - (filter (name: name != "default.nix")) - f - (map (name: dir + "/${name}")) - ] - else []; - loadImports = with final; flip youthlic.loadImports' (x: x); + final.pipe dir [ + final.youthlic.loadImports + f + ]; + loadImports = dir: + with final; + if !(pathExists dir && builtins.readFileType dir == "directory") + then [] + else let + items = pipe dir [builtins.readDir attrNames]; + in + pipe items [ + (concatMap + (name: let + path = dir + "/${name}"; + type = builtins.readFileType path; + in + if type == "directory" + then + if pathExists (path + "/default.nix") + then [path] + else youthlic.loadImports path + else if type == "regular" + then + if hasSuffix ".nix" name + then [path] + else [] + else [])) + (filter (name: !hasSuffix "/default.nix" (toString name))) + ]; }; } diff --git a/nixos/configurations/Tytonidae/specialisation/default.nix b/nixos/configurations/Tytonidae/specialisation/default.nix deleted file mode 100644 index 1f8bd9e..0000000 --- a/nixos/configurations/Tytonidae/specialisation/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -{lib, ...}: { - imports = lib.youthlic.loadImports ./.; -} diff --git a/nixos/modules/default.nix b/nixos/modules/default.nix index f70ea62..d4b1c42 100644 --- a/nixos/modules/default.nix +++ b/nixos/modules/default.nix @@ -1,3 +1,3 @@ {lib, ...}: { - imports = with lib; youthlic.loadImports' ./. (filter (name: name != "top-level")); + imports = with lib; youthlic.loadImports' ./. (filter (name: !hasSuffix "/top-level" (toString name))); } diff --git a/nixos/modules/programs/default.nix b/nixos/modules/programs/default.nix deleted file mode 100644 index 1f8bd9e..0000000 --- a/nixos/modules/programs/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -{lib, ...}: { - imports = lib.youthlic.loadImports ./.; -} diff --git a/nixos/modules/virtualisation/default.nix b/nixos/modules/virtualisation/default.nix deleted file mode 100644 index 1f8bd9e..0000000 --- a/nixos/modules/virtualisation/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -{lib, ...}: { - imports = lib.youthlic.loadImports ./.; -}