diff options
author | sterni <sternenseemann@systemli.org> | 2024-03-31T19·03+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-04-03T11·52+0000 |
commit | c59e11dc3e6b57dd11feabd3478e95bd384eebcb (patch) | |
tree | 56ba6bd2b775c5ed1c7fbcf24bddd66fddbbbbae /nix | |
parent | 32724d28eeb7eb5f9e695993e792e79ba61be933 (diff) |
fix(nix/buildkite): solve bogus realpath errors if build steps fail r/7848
- Set pipefail to make sure the correct exit code gets returned. - Don't let xargs(1) call realpath(1) if the build fails (and nothing is printed to stdout). Change-Id: I526a18df877601d884b83862da5f37336cdf52cd Reviewed-on: https://cl.tvl.fyi/c/depot/+/11312 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'nix')
-rw-r--r-- | nix/buildkite/default.nix | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/nix/buildkite/default.nix b/nix/buildkite/default.nix index 6e158ae6c6c0..b7715e902f73 100644 --- a/nix/buildkite/default.nix +++ b/nix/buildkite/default.nix @@ -47,6 +47,9 @@ rec { # Create build command for an attribute path pointing to a derivation. mkBuildCommand = { attrPath, drvPath, outLink ? "result" }: concatStringsSep " " [ + # If the nix build fails, the Nix command's exit status should be used. + "set -o pipefail;" + # First try to realise the drvPath of the target so we don't evaluate twice. # Nix has no concept of depending on a derivation file without depending on # at least one of its `outPath`s, so we need to discard the string context @@ -55,7 +58,7 @@ rec { # To make this more uniform with how nix-build(1) works, we call realpath(1) # on nix-store(1)'s output since it has the habit of printing the path of the # out link, not the store path. - "(nix-store --realise '${drvPath}' --add-root '${outLink}' --indirect | xargs realpath)" + "(nix-store --realise '${drvPath}' --add-root '${outLink}' --indirect | xargs -r realpath)" # Since we don't gcroot the derivation files, they may be deleted by the # garbage collector. In that case we can reevaluate and build the attribute |