Nix Installation Guide: Difference between revisions

imported>Tomberek
No edit summary
imported>Mic92
nix --store awesomeness
Line 14: Line 14:
== Installing without root permissions ==
== Installing without root permissions ==


By using [https://github.com/lethalman/nix-user-chroot nix-user-chroot] or [https://github.com/proot-me/PRoot PRoot],
By using the <code>--store</code> parameter in nix 2.0  or [https://github.com/proot-me/PRoot PRoot],
you can use Nix on systems where you have no permission to create the `/nix` directory.
you can use Nix on systems where you have no permission to create the `/nix` directory.
<code>nix-user-chroot</code> is the preferred and faster option.
<code>nix run</code> is the preferred and faster option.
However, it might not run on older Linux kernels, or kernels without user namespace support.
However, it might not run on older Linux kernels, or kernels without user namespace support.
With the following command, you can test whether your system supports user namespaces:
With the following command, you can test whether your system supports user namespaces:
Line 38: Line 38:


If the output of this command is <code>CONFIG_USER_NS=y</code>, then your system supports user namespaces.
If the output of this command is <code>CONFIG_USER_NS=y</code>, then your system supports user namespaces.
=== nix 2.0's native method ===
The following command will create a nix store in <code>~/my-nix</code> and spawn a shell, where <code>~/my-nix</code> be mounted to <code>/nix</code>
<syntaxHighlight lang="console">
$ nix-shell --store ~/my-nix -p nix bashInteractive
</syntaxHighlight>


=== nix-user-chroot ===
=== nix-user-chroot ===


[https://github.com/lethalman/nix-user-chroot nix-user-chroot] was the preferred method before nix 2.0 to use nix on systems without <code>/nix</code>. It also requires user namespaces like the <code>--store</code> parameter in nix 2.0.
<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.