8

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 :)

Community
  • 1
  • 1
mguijarr
  • 7,641
  • 6
  • 45
  • 72

2 Answers2

3

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.

brainrape
  • 326
  • 2
  • 7
  • 2
    I just got it working as of Nix 2.0.4. It isn't too hard, just undocumented. [Code here](https://github.com/jefdaj/nix-no-root). – jefdaj Sep 05 '18 at 17:20
3

Future people from Google, it's still unsupported but does work. Script here that installs a couple dependencies, builds a temporary Nix, and uses that to install a proper version in your directory of choice.

jefdaj
  • 2,025
  • 2
  • 21
  • 33