fix(nix/buildkite): solve bogus realpath errors if build steps fail
- 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>
This commit is contained in:
parent
32724d28ee
commit
c59e11dc3e
1 changed files with 4 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue