From ff38ae6c5f64ceadb307eac95bbe63e7a55f80c6 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 9 Dec 2019 03:16:02 +0000 Subject: [PATCH] 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`. --- read-tree.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/read-tree.nix b/read-tree.nix index b2f161e88..2e182dfbd 100644 --- a/read-tree.nix +++ b/read-tree.nix @@ -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