I noticed building my home-manager configuration on one of my machines fails due to a “no space left on device” errror.
Took me a while to realize, that there is plenty of space in /nix, but not enough in /tmp, where the sandbox build directory seems to be created.
> rustc-LLVM ERROR: IO failure on output stream: No space left on device
> error: could not compile `util` (lib)
> warning: build failed, waiting for other jobs to finish...
> error: failed to write bytecode to /build/source/target/x86_64-unknown-linux-gnu/release/deps/language-c16d310478aa5fb8.language.eef0e8f1ec19b467-cgu.0.rcgu.b
c: No space left on device (os error 28)
(Why it builds this package and does not just download it is another story).
As far as I can see, the build directory is placed in /tmp, which only has 4GB of free space due to being a tmpfs.
Question:
Is there a way to permanently put the sandbox and its build directory somewhere else? The btrfs partition where /nix and /var/home/ are located has 190GB free…
As this machine only has 8GB of RAM, a tmpfs might simply not be big enough.
I checked the manpage for nix.conf, but found no hint. Or maybe I am just overlooking it.
Fyi, this is why NixOS normally doesn’t make /tmp a tmpfs.
Does feel a bit backwards, though, it’d make more sense to just give nix a separate build directory. Never thought this hard about why it’s done this way.
It’s done this way because the most obvious way to get a temporary directory is to put it in $TMPDIR falling back to /tmp. Unfortunately, that is very much the wrong fallback for something like a Nix build, and it ought to default to /var/tmp, per the subset of the Filesystem Hierarch Standard that NixOS does adhere to.
Just setting the build-dir in /etc/nix/nix.conf does not work, at least not with home-manager.
I need to use TMPDIR=/var/tmp/ home-manager ... for it to use /var/tmp/ instead of /tmp. Looking for a way to configure this in the home-manager configuration, so I do not need to remember this all the time…
Thanks for the link. I have no clue how the build-dir is mapped internally. But as it replaces the “old” way of setting a TMPDIR in the nix-daemon unit file, I am not sure if this bug still applies…