Move tmpDirInSandbox to initTmpDir

This commit is contained in:
Matthew Bauer 2019-10-13 16:41:49 -04:00
parent 499b038875
commit 96c84937c4

View file

@ -1961,13 +1961,6 @@ void DerivationGoal::startBuilder()
auto drvName = storePathToName(drvPath); auto drvName = storePathToName(drvPath);
tmpDir = createTempDir("", "nix-build-" + drvName, false, false, 0700); tmpDir = createTempDir("", "nix-build-" + drvName, false, false, 0700);
/* In a sandbox, for determinism, always use the same temporary
directory. */
#if __linux__
tmpDirInSandbox = useChroot ? settings.sandboxBuildDir : tmpDir;
#else
tmpDirInSandbox = tmpDir;
#endif
chownToBuilder(tmpDir); chownToBuilder(tmpDir);
/* Substitute output placeholders with the actual output paths. */ /* Substitute output placeholders with the actual output paths. */
@ -2385,7 +2378,6 @@ void DerivationGoal::startBuilder()
int res = helper.wait(); int res = helper.wait();
if (res != 0 && settings.sandboxFallback) { if (res != 0 && settings.sandboxFallback) {
useChroot = false; useChroot = false;
tmpDirInSandbox = tmpDir;
initTmpDir(); initTmpDir();
goto fallback; goto fallback;
} else if (res != 0) } else if (res != 0)
@ -2443,6 +2435,14 @@ void DerivationGoal::startBuilder()
void DerivationGoal::initTmpDir() { void DerivationGoal::initTmpDir() {
/* In a sandbox, for determinism, always use the same temporary
directory. */
#if __linux__
tmpDirInSandbox = useChroot ? settings.sandboxBuildDir : tmpDir;
#else
tmpDirInSandbox = tmpDir;
#endif
/* In non-structured mode, add all bindings specified in the /* In non-structured mode, add all bindings specified in the
derivation via the environment, except those listed in the derivation via the environment, except those listed in the
passAsFile attribute. Those are passed as file names pointing passAsFile attribute. Those are passed as file names pointing