From 267d9e100cec6b978acee1b8e7674d5d41a21a8f Mon Sep 17 00:00:00 2001 From: Emily Date: Thu, 31 Jul 2025 18:43:22 +0100 Subject: [PATCH] libstore: simplify fallback build directory logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This does change the behaviour when the global temporary directory does not exist, but other uses of the global temporary directory are already broken in that circumstance, and it should be fixed centrally if the use case is considered desirable. The logic was not present before the recent churn around build directories – it was added now that Lix is taking ownership of the build directory in the store – so this should not be a meaningful regression. Change-Id: I6a6a69648054ae201b3ce36d11e49c93793fdb0e --- lix/libstore/build/local-derivation-goal.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lix/libstore/build/local-derivation-goal.cc b/lix/libstore/build/local-derivation-goal.cc index e0e14b09f..be7c1a08c 100644 --- a/lix/libstore/build/local-derivation-goal.cc +++ b/lix/libstore/build/local-derivation-goal.cc @@ -457,8 +457,6 @@ try { throw; } - auto globalTmp = defaultTempDir(); - createDirs(globalTmp); #if __APPLE__ /* macOS filesystem namespacing does not exist, to avoid breaking builds, we need to weaken * the mode bits on the top-level directory. This avoids issues like @@ -468,7 +466,7 @@ try { constexpr int toplevelDirMode = 0700; #endif auto nixBuildsTmp = createTempDir( - globalTmp, fmt("nix-builds-%s", geteuid()), false, false, toplevelDirMode + "", fmt("nix-builds-%s", geteuid()), false, false, toplevelDirMode ); warn( "Failed to use the system-wide build directory '%s', falling back to a temporary " @@ -476,10 +474,10 @@ try { settings.buildDir.get(), nixBuildsTmp ); - worker.buildDirOverride = nixBuildsTmp; tmpDirRoot = createTempDir( nixBuildsTmp, "nix-build-" + std::string(drvPath.name()), false, false, 0700 ); + worker.buildDirOverride = nixBuildsTmp; } /* The TOCTOU between the previous mkdir call and this open call is unavoidable due to * POSIX semantics.*/