Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 656
mguijarr Avatar asked Jul 26 '16 08:07

mguijarr


People also ask

How do I install Nix at home?

To install Nix, run curl -L https://nixos.org/nix/install | sh as a non-root user and follow the instructions. Alternatively, you may prefer to download the installation script and verify its integrity using GPG signatures. Instructions for doing so can be found here: https://nixos.org/nix/download.html.

Where does Nix install packages?

When you ask Nix to install a package, it will first try to get it in pre-compiled form from a binary cache. By default, Nix will use the binary cache https://cache.nixos.org; it contains binaries for most packages in Nixpkgs. Only if no binary is available in the binary cache, Nix will build the package from source.

How does Nix package manager work?

Nix is a cross-platform package manager that utilizes a purely functional deployment model where software is installed into unique directories generated through cryptographic hashes. It is also the name of the tool's programming language.


2 Answers

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.

like image 130
brainrape Avatar answered Sep 28 '22 16:09

brainrape


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.

like image 38
jefdaj Avatar answered Sep 28 '22 17:09

jefdaj