forked from extern/flakelight
Extend autoloading to include importable directories
Now if a dir is treated as an attrset, subdirs with `default.nix` will be loaded as attrs.
This commit is contained in:
parent
cf3a2e5496
commit
ec343ae967
@ -100,12 +100,15 @@ let
|
|||||||
(pipe (readDir path) [
|
(pipe (readDir path) [
|
||||||
attrNames
|
attrNames
|
||||||
(filter (s: s != "default.nix"))
|
(filter (s: s != "default.nix"))
|
||||||
(filter (hasSuffix ".nix"))
|
(filter (s: (hasSuffix ".nix" s)
|
||||||
|
|| pathExists (path + "/${s}/default.nix")))
|
||||||
(map (removeSuffix ".nix"))
|
(map (removeSuffix ".nix"))
|
||||||
(map (removePrefix "_"))
|
(map (removePrefix "_"))
|
||||||
])
|
])
|
||||||
(p: import (path + (if pathExists
|
(p: import (path +
|
||||||
(path + "/_${p}.nix") then "/_${p}.nix" else "/${p}.nix")));
|
(if pathExists (path + "/_${p}.nix") then "/_${p}.nix"
|
||||||
|
else if pathExists (path + "/${p}.nix") then "/${p}.nix"
|
||||||
|
else "/${p}")));
|
||||||
|
|
||||||
autoImport = dir: name:
|
autoImport = dir: name:
|
||||||
if isList name
|
if isList name
|
||||||
|
Loading…
Reference in New Issue
Block a user