Search code examples
home-directorynix

Nix tutorial on installing in home directory


I am trying to follow this tutorial, in order to install the Nix package manager in my home directory instead of /nix.

I am doing the PRoot installation (see 2. in tutorial). At the end, the tutorial proposes to be smart in Building native packages section, to be able to run packages without PRoot:

To run packages natively (without PRoot) they have to be build from source because all paths to the nix store are hard-coded. It is simple, really:

mkdir $HOME/nix

nix-channel --update

env NIX_STORE_DIR=$HOME/nix nix-env -i nix

And now your Nix store gets built up using the new paths. The built binaries can be run directly from there.

I did that, but I don't see how it frees me from PRoot. If I don't do the /nix mounting point with PRoot, nothing works (no nix-env executable, I can't install new packages).

Should this NIX_STORE_DIR environment variable be put in my .bashrc ?

It seems I always need to run PRoot because ~/.nix-profile points to a /nix/... directory:

.nix-profile -> /nix/var/nix/profiles/default

There are more steps in the tutorial (5., 6.) - should I follow them ? It seems they apply only in case of using the manual installation (step 4.), although it is not explicit.

Any help would be appreciated :)


Solution

  • For anyone stumbling on this old question: there is no currently supported way to install Nix without root. The above wiki was moved to https://nixos.wiki/wiki/Nix_Installation_Guide . It may well be out of date. PRoot could work, but even then, rebuilding the whole store at a different path is not a good idea, not the least because the binary caches won't help and you'll need to build everything.

    I suggest trying Nix in a virtual machine or cloud server.