Skip to content

chore: respect TMPDIR for local builds - #331

Closed
weriomat wants to merge 1 commit into
serokell:masterfrom
weriomat:tmpdir
Closed

chore: respect TMPDIR for local builds#331
weriomat wants to merge 1 commit into
serokell:masterfrom
weriomat:tmpdir

Conversation

@weriomat

Copy link
Copy Markdown
Contributor

This fixes #283.

@heitor-lassarote

Copy link
Copy Markdown
Member

Thank you for this fix. I tried reproducing this bug locally, and I think this fix matters a bit less now.

Nix changed this on purpose: commit 88b7db1b ("Don't default build-dir to temp-dir, store setting", March 2025) moved the default build directory from $TMPDIR to a subdirectory of nixStateDir, as a hardening measure against sandbox escapes. So before that commit, TMPDIR was respected by default, which is likely why this fix worked when you wrote it.

On current Nix, for a multi-user (daemon) install, the daemon uses <stateDir>/builds (like /nix/var/nix/builds) and TMPDIR has no effect anymore. I confirmed this on both current Nix and the 2.24.12 this repo's nixpkgs pins. --option build-dir <path> still works there.

For a single-user (non-daemon) install, TMPDIR is still respected, but Command already inherits the parent's environment by default, so that case should work regardless of this change.

Could you share what setup and Nix version you tested against? Want to make sure I'm not missing something before deciding how to move forward here.

@weriomat

weriomat commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

I have not checked in with this PR in a long time. With this PR I wanted to help out the OP in #283 but never ran into this problem myself.

As I only use multi user installs I cant test the single user one. Thus I am closing this PR.

Thank you for looking at this PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$TMPDIR env var not entirely respected in local builds

2 participants