about summary refs log tree commit diff
path: root/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'default.nix')
-rw-r--r--default.nix19
1 files changed, 17 insertions, 2 deletions
diff --git a/default.nix b/default.nix
index 151d8987ea3d..61821bce8fc2 100644
--- a/default.nix
+++ b/default.nix
@@ -50,10 +50,25 @@ let
 
   # Walk the tree starting with 'node', recursively extending the list
   # of build targets with anything that looks buildable.
+  #
+  # Any tree node can specify logical targets by exporting a
+  # 'meta.targets' attribute containing a list of keys in itself. This
+  # enables target specifications that do not exist on disk directly.
   gather = node:
     if node ? __readTree then
-      (if eligible node then [node] else []) ++
-      concatMap gather (attrValues node)
+      # Include the node itself if it is eligible.
+      (if eligible node then [ node ] else [])
+      # Include eligible children of the node
+      ++ concatMap gather (attrValues node)
+      # 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;
+             __subtarget = k;
+           })
+           (node.meta.targets or []))
     else [];
 in fix(self: {
   config = config self;