Skip to content

Commit

Permalink
Move macOS TMPDIR hack from initNix to initLibStore
Browse files Browse the repository at this point in the history
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 NixOS#7731
  • Loading branch information
roberth committed Feb 5, 2023
1 parent 0992b41 commit a04bcec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/libmain/shared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,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

}


Expand Down
8 changes: 8 additions & 0 deletions src/libstore/globals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,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;
}

Expand Down

0 comments on commit a04bcec

Please sign in to comment.