Search code examples
nix

Can nix be installed in a different location other than /nix?


After some time, I am starting to run out of disk space in my development machine (only 128GB). For this reason, I have decided to move local cache stores (.npm, .m2, .ivy2, etc.) to an external drive.

I switched recently to Nix for Haskell development after experiencing the well known "cabal hell". I haven't found a proper way to change the Nix store location, though.

Is it possible?


Solution

  • Yes, but you won't be able to use the binary packages (everything will be compiled from scratch). To bootstrap, see https://nixos.org/wiki/How_to_install_nix_in_home_%28on_another_distribution%29

    A better idea might be to make /nix be a symlink to a directory on your external drive. Have you considered this? As @jarandaf mentions below, /nix cannot be a symlink.