diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 74a68e1f5baf..ecb835062897 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -3591,8 +3591,15 @@ void DerivationGoal::registerOutputs() if (buildMode == bmRepair) replaceValidPath(path, actualPath); else - if (buildMode != bmCheck && rename(actualPath.c_str(), worker.store.toRealPath(path).c_str()) == -1) - throw SysError(format("moving build output '%1%' from the sandbox to the Nix store") % path); + if (buildMode != bmCheck && rename(actualPath.c_str(), worker.store.toRealPath(path).c_str())) { + if(errno == EACCESS) { + // No need to free since we are in a chroot, and that gets deleted later. + // Hope it's a source problem + copyPath(actualPath, worker.store.toRealPath(path)); + } else { + throw SysError(format("moving build output '%1%' from the sandbox to the Nix store") % path); + } + } } if (buildMode != bmCheck) actualPath = worker.store.toRealPath(path); }