fix(read-tree): Don't import default.nix sibling expression

If a folder contains a `default.nix`, Nix expressions contained in
adjacent files should not be imported (they might be things like a
`shell.nix` or a `deps.nix` which do not evaluate to derivations).

The tree traversal still continues for all children folders of a
folder with a `default.nix`.
This commit is contained in:
Vincent Ambo 2019-12-09 03:16:02 +00:00
parent 7044424f52
commit ff38ae6c5f

View file

@ -72,10 +72,12 @@ let
in listToAttrs (imported ++ dirs);
importOr = path: dir: f:
let contents = f path (attrsToList dir);
let
allContents = f path (attrsToList dir);
dirOnlyContents = f path (filter (f: f.value == "directory") (attrsToList dir));
in if dir ? "default.nix"
then import path (argsWithPath args (pathParts path)) // contents
else contents;
then import path (argsWithPath args (pathParts path)) // dirOnlyContents
else allContents;
readTree = path: importOr path (readDir path) traverse;
in readTree initPath