about summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-02-07T10·24+0300
committertazjin <tazjin@tvl.su>2022-02-07T15·13+0000
commit3bde42586089a28a49dc063c2e639194211cb9af (patch)
treef137b907fc6a2a49f20ff0499d2c01e78e8a03a1 /nix
parent98b6af02f525bdf61de806ffd8545f0b5a3fa817 (diff)
refactor(nix): Move `mkLabel` from buildkite to readTree r/3774
This function is more generically useful than just for pipeline
construction.

A subsequent commit will use it inside of readTree itself.

Change-Id: I5eabd6f659726484667e060958865dddbc205762
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5237
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'nix')
-rw-r--r--nix/buildkite/default.nix10
-rw-r--r--nix/readTree/default.nix9
2 files changed, 10 insertions, 9 deletions
diff --git a/nix/buildkite/default.nix b/nix/buildkite/default.nix
index d299d52624..eb8061cf6b 100644
--- a/nix/buildkite/default.nix
+++ b/nix/buildkite/default.nix
@@ -6,7 +6,7 @@
 #
 # The structure of the file that is being created is documented here:
 #   https://buildkite.com/docs/pipelines/defining-steps
-{ pkgs, ... }:
+{ depot, pkgs, ... }:
 
 let
   inherit (builtins)
@@ -29,6 +29,7 @@ let
     unsafeDiscardStringContext;
 
   inherit (pkgs) lib runCommandNoCC writeText;
+  inherit (depot.nix.readTree) mkLabel;
 in
 rec {
   # Creates a Nix expression that yields the target at the specified
@@ -46,13 +47,6 @@ rec {
     in
     if target ? __subtarget then subtargetExpr else targetExpr;
 
-  # Create a pipeline label from the target's tree location.
-  mkLabel = target:
-    let label = concatStringsSep "/" target.__readTree;
-    in if target ? __subtarget
-    then "${label}:${target.__subtarget}"
-    else label;
-
   # Determine whether to skip a target if it has not diverged from the
   # HEAD branch.
   shouldSkip = parentTargetMap: label: drvPath:
diff --git a/nix/readTree/default.nix b/nix/readTree/default.nix
index 22815a44c4..5d2e1fff6a 100644
--- a/nix/readTree/default.nix
+++ b/nix/readTree/default.nix
@@ -58,6 +58,13 @@ let
     __readTreeChildren = builtins.attrNames children;
   };
 
+  # Create a label from a target's tree location.
+  mkLabel = target:
+    let label = concatStringsSep "/" target.__readTree;
+    in if target ? __subtarget
+    then "${label}:${target.__subtarget}"
+    else label;
+
   # Merge two attribute sets, but place attributes in `passthru` via
   # `overrideAttrs` for derivation targets that support it.
   merge = a: b:
@@ -188,7 +195,7 @@ let
   isDerivation = x: isAttrs x && x ? type && x.type == "derivation";
 in
 {
-  inherit gather;
+  inherit gather mkLabel;
 
   __functor = _:
     { path