about summary refs log tree commit diff
path: root/nix/buildkite/default.nix
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2024-02-13T17·00+0100
committerclbot <clbot@tvl.fyi>2024-03-02T23·39+0000
commit1608f935aad2696f38231ef779bffc1f5ac31fec (patch)
tree7821a035a10f0a3a12c5b7cb7aef515c31aa6ee6 /nix/buildkite/default.nix
parent206742949bd8778e3209592f275dd29774c909c7 (diff)
refactor(nix/buildkite): unify target attr path calculation r/7630
After the previous refactor that made mkBuildExpr use attribute paths,
mkStep and mkDrvMap can now share the code for calculating the attribute
path of any given target.

Change-Id: I50f9687e85c3b4407e4a55ff7e645db882bb80d6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10849
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'nix/buildkite/default.nix')
-rw-r--r--nix/buildkite/default.nix15
1 files changed, 9 insertions, 6 deletions
diff --git a/nix/buildkite/default.nix b/nix/buildkite/default.nix
index e45deade4bea..45af87784c58 100644
--- a/nix/buildkite/default.nix
+++ b/nix/buildkite/default.nix
@@ -59,6 +59,13 @@ rec {
     "|| (test ! -f '${drvPath}' && nix-build -E '${mkBuildExpr attrPath}' --show-trace)"
   ];
 
+  # Attribute path of a target relative to the depot root. Needs to take into
+  # account whether the target is a physical target (which corresponds to a path
+  # in the filesystem) or the subtarget of a physical target.
+  targetAttrPath = target:
+    target.__readTree
+    ++ lib.optionals (target ? __subtarget) [ target.__subtarget ];
+
   # Create a pipeline step from a single target.
   mkStep = { headBranch, parentTargetMap, target, cancelOnBuildFailing }:
     let
@@ -70,9 +77,7 @@ rec {
       key = hashString "sha1" label;
       skip = shouldSkip { inherit label drvPath parentTargetMap; };
       command = mkBuildCommand {
-        attrPath =
-          target.__readTree
-          ++ lib.optionals (target ? __subtarget) [ target.__subtarget ];
+        attrPath = targetAttrPath target;
         inherit drvPath;
       };
       env.READTREE_TARGET = label;
@@ -257,9 +262,7 @@ rec {
 
         # Include the attrPath in the output to reconstruct the drv
         # without parsing the human-readable label.
-        attrPath = target.__readTree ++ lib.optionals (target ? __subtarget) [
-          target.__subtarget
-        ];
+        attrPath = targetAttrPath target;
       };
     })
     drvTargets)));