From 33122e79dfe51f143158a25a087f7aa0a2bf19d0 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 28 Jun 2025 17:37:43 +0200 Subject: [PATCH] libstore: weaken the top-level fallback temp dir to 0755 for macOS Under macOS, the first level of directory has actually mode 0755 instead of 0700 as macOS often do not possess the right primitives to chroot inside of these directories, leading to https://github.com/NixOS/nix/pull/11031. Thanks to Emily for the heads-up on this type of matter. Change-Id: I9d4e53717f61c9d573ff176f820610612804fbc3 Signed-off-by: Raito Bezarius --- lix/libstore/build/local-derivation-goal.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lix/libstore/build/local-derivation-goal.cc b/lix/libstore/build/local-derivation-goal.cc index ab8f01f55..618f751eb 100644 --- a/lix/libstore/build/local-derivation-goal.cc +++ b/lix/libstore/build/local-derivation-goal.cc @@ -459,8 +459,17 @@ try { auto globalTmp = defaultTempDir(); createDirs(globalTmp); - auto nixBuildsTmp = - createTempDir(globalTmp, fmt("nix-builds-%s", geteuid()), false, false, 0700); +#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 + * https://github.com/NixOS/nix/pull/11031. */ + constexpr int toplevelDirMode = 0755; +#else + constexpr int toplevelDirMode = 0700; +#endif + auto nixBuildsTmp = createTempDir( + globalTmp, fmt("nix-builds-%s", geteuid()), false, false, toplevelDirMode + ); warn( "Failed to use the system-wide build directory '%s', falling back to a temporary " "directory inside '%s'",