diff options
author | Vincent Ambo <mail@tazj.in> | 2022-02-02T09·22+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-02-02T13·36+0000 |
commit | bb140e16a2d44bbfe96911f29f1b6c5ef4947b85 (patch) | |
tree | 1e4c43dd2f695ee31f8489017339cc77c17ff11a | |
parent | ba7197c271d54fd806970738e883b39c8ae1a3a9 (diff) |
feat(nix/buildkite): Add parentOverride argument to extra steps r/3743
This can be used to override the parent derivation if its output is required, for example to inject versions which are only used during releases to avoid cache-busting. Change-Id: I2211496efa8f9bc98ea43b23e4f3f92c61a6da73 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5184 Tested-by: BuildkiteCI Autosubmit: tazjin <tazjin@tvl.su> Reviewed-by: ezemtsov <eugene.zemtsov@gmail.com>
-rw-r--r-- | nix/buildkite/default.nix | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/nix/buildkite/default.nix b/nix/buildkite/default.nix index d17b5c86c4a6..b1653e1ad5f2 100644 --- a/nix/buildkite/default.nix +++ b/nix/buildkite/default.nix @@ -159,6 +159,13 @@ rec { let step = mkStep headBranch parentTargetMap target; + # Same step, but with an override function applied. This is + # used in mkExtraStep if the extra step needs to modify the + # parent derivation somehow. + # + # Note that this will never affect the label. + overridable = f: mkStep headBranch parentTargetMap (f target); + # Split build/post-build steps splitExtraSteps = partition ({ postStep, ... }: postStep) (attrValues (mapAttrs @@ -168,7 +175,7 @@ rec { }) (target.meta.ci.extraSteps or { }))); - mkExtraStep' = { name, value, ... }: mkExtraStep step name value; + mkExtraStep' = { name, value, ... }: mkExtraStep overridable name value; extraBuildSteps = map mkExtraStep' splitExtraSteps.wrong; # 'wrong' -> no prompt extraPostSteps = map mkExtraStep' splitExtraSteps.right; # 'right' -> has prompt in @@ -260,6 +267,10 @@ rec { # command. Output will be available as 'result'. # TODO: Figure out multiple-output derivations. # + # parentOverride (optional): A function (drv -> drv) to override + # the parent's target definition when preparing its output. Only + # used in extra steps that use needsOutput. + # # branches (optional): Git references (branches, tags ... ) on # which this step should be allowed to run. List of strings. # @@ -291,15 +302,18 @@ rec { # Create the Buildkite configuration for an extra step, optionally # wrapping it in a gate group. - mkExtraStep = parent: key: { command - , label ? key - , prompt ? false - , needsOutput ? false - , branches ? null - , alwaysRun ? false - , postBuild ? false - }@cfg: + mkExtraStep = overridableParent: key: + { command + , label ? key + , prompt ? false + , needsOutput ? false + , parentOverride ? (x: x) + , branches ? null + , alwaysRun ? false + , postBuild ? false + }@cfg: let + parent = overridableParent parentOverride; parentLabel = parent.env.READTREE_TARGET; step = { |