From d23716f3543c35a0b672a5b508f7e3afc39c0aa0 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 2 Dec 2019 15:05:54 +0000 Subject: refactor(read-tree): Keep traversing even if a default.nix is found This makes it possible for people to drop a default.nix into folders along the way that add additional things into the attribute set at that level. These default.nix files are imported and merged with the rest of the traversal from that point on. In theory nothing stops a user from putting a derivation into one of them, but the effects of merging that derivation's underlying attribute set with random other things from the traversal are undefined. This feature is being introduced for a slight revamp of the thirdParty layout. --- read-tree.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'read-tree.nix') diff --git a/read-tree.nix b/read-tree.nix index d742c69ea411..6f900a0667db 100644 --- a/read-tree.nix +++ b/read-tree.nix @@ -31,7 +31,7 @@ let in if res == null then null else head res; filterNixFiles = dir: - let files = filter (e: isFile e.value) dir; + let files = filter (e: isFile e.value && e.name != "default.nix") dir; nixFiles = map (f: { # Name and value are intentionally flipped to get the # correct attribute set structure back out @@ -70,9 +70,10 @@ let in listToAttrs (imported ++ dirs); importOr = path: dir: f: - if dir ? "default.nix" - then import path (argsWithPath args (pathParts path)) - else f path (attrsToList dir); + let contents = f path (attrsToList dir); + in if dir ? "default.nix" + then import path (argsWithPath args (pathParts path)) // contents + else contents; readTree = path: importOr path (readDir path) traverse; in readTree initPath -- cgit 1.4.1