feat(read-tree): Mark derivations that have children

Adds a `__treeChildren` attribute that is set to `true` on derivations
that have children, e.g. for cases where a folder contains a
`default.nix` but has subdirectories with additional things in them.
This commit is contained in:
Vincent Ambo 2019-12-09 19:51:15 +00:00
parent c81be2f836
commit 2b6b76570e

View file

@ -1,7 +1,4 @@
# TODO(tazjin): avoid {} by only calling functions *after* checking what they are
# TODO(tazjin): add an attribute to derivations that have children to
# indicate that traversal should continue for ... traversal use-cases
# (such as CI package filtering)
args: initPath:
@ -78,7 +75,9 @@ 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)) // dirOnlyContents
then import path (argsWithPath args (pathParts path))
// { __treeChildren = true; } # used downstream for traversals
// dirOnlyContents
else allContents;
readTree = path: importOr path (readDir path) traverse;