aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2023-02-01 17:35:28 +0100
committerRobert Hensing <robert@roberthensing.nl>2023-04-07 16:24:18 +0200
commit52d6ce6515ff1e8462b67b2adb1942477ce122f8 (patch)
tree4be6fc7642d5f0ef37824ae61c18e3109397a4dc /src
parente706ffa007120249deace149dc4ba7cacf2c8beb (diff)
Move macOS TMPDIR hack from initNix to initLibStore
This code is bad. We shouldn't unset variables in programs whose children may need them. Fixing one issue at a time, so postponing. See https://github.com/NixOS/nix/issues/7731 Part of an effort to make it easier to initialize the right things, by moving code into the appropriate libraries.
Diffstat (limited to 'src')
-rw-r--r--src/libmain/shared.cc8
-rw-r--r--src/libstore/globals.cc8
2 files changed, 8 insertions, 8 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index cbd80756e..2a7e09e65 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -169,14 +169,6 @@ void initNix()
gettimeofday(&tv, 0);
srandom(tv.tv_usec);
- /* On macOS, don't use the per-session TMPDIR (as set e.g. by
- sshd). This breaks build users because they don't have access
- to the TMPDIR, in particular in ‘nix-store --serve’. */
-#if __APPLE__
- if (hasPrefix(getEnv("TMPDIR").value_or("/tmp"), "/var/folders/"))
- unsetenv("TMPDIR");
-#endif
-
}
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index 6848991a2..5a8825be5 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -343,6 +343,14 @@ void initLibStore() {
preloadNSS();
+ /* On macOS, don't use the per-session TMPDIR (as set e.g. by
+ sshd). This breaks build users because they don't have access
+ to the TMPDIR, in particular in ‘nix-store --serve’. */
+#if __APPLE__
+ if (hasPrefix(getEnv("TMPDIR").value_or("/tmp"), "/var/folders/"))
+ unsetenv("TMPDIR");
+#endif
+
initLibStoreDone = true;
}