summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nix/libstore/build.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 67ebfe2f146..43a8a371846 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -2369,15 +2369,6 @@ void DerivationGoal::registerOutputs()
2369 Path actualPath = path; 2369 Path actualPath = path;
2370 if (useChroot) { 2370 if (useChroot) {
2371 actualPath = chrootRootDir + path; 2371 actualPath = chrootRootDir + path;
2372 if (pathExists(actualPath)) {
2373 /* Move output paths from the chroot to the store. */
2374 if (buildMode == bmRepair)
2375 replaceValidPath(path, actualPath);
2376 else
2377 if (buildMode != bmCheck && rename(actualPath.c_str(), path.c_str()) == -1)
2378 throw SysError(format("moving build output `%1%' from the chroot to the store") % path);
2379 }
2380 if (buildMode != bmCheck) actualPath = path;
2381 } else { 2372 } else {
2382 Path redirected = redirectedOutputs[path]; 2373 Path redirected = redirectedOutputs[path];
2383 if (buildMode == bmRepair 2374 if (buildMode == bmRepair
@@ -2463,6 +2454,20 @@ void DerivationGoal::registerOutputs()
2463 canonicalisePathMetaData(actualPath, 2454 canonicalisePathMetaData(actualPath,
2464 buildUser.enabled() && !rewritten ? buildUser.getUID() : -1, inodesSeen); 2455 buildUser.enabled() && !rewritten ? buildUser.getUID() : -1, inodesSeen);
2465 2456
2457 if (useChroot) {
2458 if (pathExists(actualPath)) {
2459 /* Now that output paths have been canonicalized (in particular
2460 there are no setuid files left), move them outside of the
2461 chroot and to the store. */
2462 if (buildMode == bmRepair)
2463 replaceValidPath(path, actualPath);
2464 else
2465 if (buildMode != bmCheck && rename(actualPath.c_str(), path.c_str()) == -1)
2466 throw SysError(format("moving build output `%1%' from the chroot to the store") % path);
2467 }
2468 if (buildMode != bmCheck) actualPath = path;
2469 }
2470
2466 /* For this output path, find the references to other paths 2471 /* For this output path, find the references to other paths
2467 contained in it. Compute the SHA-256 NAR hash at the same 2472 contained in it. Compute the SHA-256 NAR hash at the same
2468 time. The hash is stored in the database so that we can 2473 time. The hash is stored in the database so that we can