Nix Installation Guide: Difference between revisions

imported>Mic92
improve check if userns is available.
imported>Mic92
switch to rust version of nix-user-chroot
Line 45: Line 45:
=== nix-user-chroot ===
=== nix-user-chroot ===


[https://github.com/lethalman/nix-user-chroot nix-user-chroot] is the preferred method to install use nix on systems without <code>/nix</code>. It also requires user namespaces to be enabled on the system.
[https://github.com/nix-community/nix-user-chroot nix-user-chroot] is the preferred method to install use nix on systems without <code>/nix</code>. It also requires user namespaces to be enabled on the system.
<code>nix-user-chroot</code> will create an environment in which you can bind mount an directory to <code>/nix</code>.
<code>nix-user-chroot</code> will create an environment in which you can bind mount an directory to <code>/nix</code>.
The mountpoint will be only visible within this environment.
The mountpoint will be only visible within this environment.


<code>nix-user-chroot</code> can be built the following way. (Note: This assumes a C compiler, <code>make</code> and <code>git</code>are installed.)
There are [https://github.com/nix-community/nix-user-chroot/releases pre-build static binaries]
 
and the readme also contains the instructions to build from [https://github.com/nix-community/nix-user-chroot#build-from-source source] (assuming rustc and cargo to be installed).
<syntaxHighlight lang="console">
$ git clone https://github.com/lethalman/nix-user-chroot.git
$ cd nix-user-chroot
$ make
</syntaxHighlight>
 
The last step creates an executable called <code>nix-user-chroot</code>.
 
<code>nix-user-chroot</code> can now be used to install Nix.
 
This method will also require to deactivate the build sandbox of nix, since
creating a nested sandbox is not supported:
 
<syntaxHighlight lang="console">
$ cat ~/.config/nix/nix.conf
sandbox = false
</syntaxHighlight>


In this example, the Nix store will be installed to <code>~/.nix</code>.
In this example, the Nix store will be installed to <code>~/.nix</code>.
Line 73: Line 56:
<syntaxHighlight lang="console">
<syntaxHighlight lang="console">
$ mkdir -m 0755 ~/.nix
$ mkdir -m 0755 ~/.nix
$ ./nix-user-chroot/nix-user-chroot ~/.nix bash
$ nix-user-chroot ~/.nix bash
</syntaxHighlight>
</syntaxHighlight>