Custom TMPDIR for nix-env

I am trying to install openjdk8 and the install fails due to, I suspect, noexec bit on /tmp (I am on RHEL7). How do I provide my own value for TMPDIR so that nix-env, nix-daemon, etc. see it? This is on today’s unstable.

...
configuring
no configure script, doing nothing
building
build flags: SHELL=/nix/store/zavn4np1jvm79f0rafkv0p1mrag09qkz-bash-4.4-p23/bin/bash all
No configurations found for /tmp/nix-build-openjdk-8u222-ga.drv-0/jdk8u-jdk8u222-ga/! Please run configure to create a configuration.
Makefile:55: *** Cannot continue.  Stop.
builder for '/nix/store/j848c1781bkhlrpmg4yb9r2z7632pj12-openjdk-8u222-ga.drv' failed with exit code 2
error: build of '/nix/store/j848c1781bkhlrpmg4yb9r2z7632pj12-openjdk-8u222-ga.drv' failed
2 Likes

These look somewhat related
https://github.com/NixOS/nix/issues/157
https://github.com/NixOS/nix/issues/2098

I wonder if it would be helpful if trusted users could set environment variables for things run by nix-daemon, or something like that.

It bothers me that one might have to edit a service to get this, I feel like there should be a decent way to do it without that.
You might also just be able to run another nix daemon manually, but I’ve never done that.

1 Like

Thanks! Yes, I also found the standard way to configure environments for services using that systemd command systemctl edit nix-daemon.service. I agree that given the common security practice of nonexecutable /tmp nix-daemon should have some configuration settings to set TMPDIR.

Would be good to open an issue if there isn’t one already, I didn’t look too hard.