Add space to NixOS for builds

Hello,

When I created my partition for NixOS (dual boot) I gave it around 80Go for the root on my SSD. Now, I’m running low on disk space, which can make builds fail (not enough disk space on build, e.g. when building PyTorch : super annoying error after ~2h of compilation).

Would it be possible to make NixOS do the builds on another partition (which would be on my HDD) ?

Thanks !

Would it be possible to make NixOS do the builds on another partition (which would be on my HDD) ?

Do you just want to use /tmp on HDD partition? This doesn’t require anything special.

Thanks for the reply.
Are builds performed on /tmp ?

The normal flow is: a build directory is created in /tmp, then the build installs into /nix. There is some sandboxing and some bind mounts, but they don’t change where the space gets consumed.

Thank you very much, that clarifies it.

don’t forget about nix-collect-garbage and if you are fine with nix cleaning up old profiles then you can also pass -d to it as well

Note: this will clean up anything that’s not explicitly listed in gcroots, so if you are still experimenting with nix expressions, this may “destroy” your cache.

2 Likes