Skip to content

Commit 2869595

Browse files
committed
--keep-failed with remote builders will keep the failed build directory on that builder
1 parent f8aabb0 commit 2869595

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

src/build-remote/build-remote.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,15 @@ static int main_build_remote(int argc, char * * argv)
329329
drv.inputSrcs = store->parseStorePathSet(inputs);
330330
optResult = sshStore->buildDerivation(*drvPath, (const BasicDerivation &) drv);
331331
auto & result = *optResult;
332-
if (!result.success())
332+
if (!result.success()) {
333+
if (settings.keepFailed) {
334+
warn(
335+
"The failed build directory was kept on the remote builder due to `--keep-failed`. "
336+
"If the build's architecture matches your host, you can re-run the command with `--builders ''` to disable remote building for this invocation."
337+
);
338+
}
333339
throw Error("build of '%s' on '%s' failed: %s", store->printStorePath(*drvPath), storeUri, result.errorMsg);
340+
}
334341
} else {
335342
copyClosure(*store, *sshStore, StorePathSet {*drvPath}, NoRepair, NoCheckSigs, substitute);
336343
auto res = sshStore->buildPathsWithResults({

tests/functional/build-remote.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ out="$(nix-build 2>&1 failing.nix \
8585
--arg busybox "$busybox")" || true
8686

8787
[[ "$out" =~ .*"note: keeping build directory".* ]]
88+
[[ "$out" =~ .*"The failed build directory was kept on the remote builder due to `--keep-failed`. ".* ]]
8889

8990
build_dir="$(grep "note: keeping build" <<< "$out" | sed -E "s/^(.*)note: keeping build directory '(.*)'(.*)$/\2/")"
9091
[[ "foo" = $(<"$build_dir"/bar) ]]

0 commit comments

Comments
 (0)