From d7f60bcb043925670c02a8ccf9067e97d647bc87 Mon Sep 17 00:00:00 2001 From: sterni Date: Wed, 15 Sep 2021 13:22:54 +0200 Subject: feat(nix/readTree): record list of children added by readTree This change adds a new attribute to readTree nodes, `__readTreeChildren` which is a list of attribute names added to this node by readTree. This is then used by `gather` for `ci.targets` to avoid evaluating attributes unnecessarily. Especially since Nix is not as lazy as we'd like when determining types (i. e. child ? __readTree needs to force `child` even when it's not an attribute set), evaluating attributes unnecessarily is sometimes problematic. Change-Id: I0a98691d41f987e23ee7e9ba21fbe465da5fe402 --- default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'default.nix') diff --git a/default.nix b/default.nix index 866b3fa6bf..941110b222 100644 --- a/default.nix +++ b/default.nix @@ -79,13 +79,14 @@ let # Include the node itself if it is eligible. (if eligible node then [ node ] else []) # Include eligible children of the node - ++ concatMap gather (attrValues node) + ++ concatMap gather (map (attr: node."${attr}") node.__readTreeChildren) # Include specified sub-targets of the node ++ filter eligible (map (k: (node."${k}" or {}) // { # Keep the same tree location, but explicitly mark this # node as a subtarget. __readTree = node.__readTree; + __readTreeChildren = []; __subtarget = k; }) (node.meta.targets or [])) -- cgit 1.4.1