Nix (package manager): Difference between revisions
imported>Samueldr m Missed a word. (article) |
imported>Mic92 use console syntax highlighting |
||
Line 41: | Line 41: | ||
To install Nix from any Linux distribution, use the following two commands (assumes you have the permission to use sudo and you are logged in as the user you want to install Nix for). | To install Nix from any Linux distribution, use the following two commands (assumes you have the permission to use sudo and you are logged in as the user you want to install Nix for). | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
sudo install -d -m755 -o $USER -g $USER /nix | $ sudo install -d -m755 -o $USER -g $USER /nix | ||
curl https://nixos.org/nix/install | sh | $ curl https://nixos.org/nix/install | sh | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 56: | Line 56: | ||
whether your system support user namespaces: | whether your system support user namespaces: | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
unshare --user --pid echo YES | $ unshare --user --pid echo YES | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 63: | Line 63: | ||
If the command is absent an alternative is to check the kernel compile options. | If the command is absent an alternative is to check the kernel compile options. | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
zgrep CONFIG_USER_NS /proc/config.gz | $ zgrep CONFIG_USER_NS /proc/config.gz | ||
# On some systems like Debian or Ubuntu the kernel configuration is in a different place | # On some systems like Debian or Ubuntu the kernel configuration is in a different place | ||
grep CONFIG_USER_NS /boot/config-$(uname -r) | $ grep CONFIG_USER_NS /boot/config-$(uname -r) | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 78: | Line 78: | ||
<code>nix-user-chroot</code> can be build the following way. This assumes a c compiler and make is installed. | <code>nix-user-chroot</code> can be build the following way. This assumes a c compiler and make is installed. | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
git clone https://github.com/lethalman/nix-user-chroot.git | $ git clone https://github.com/lethalman/nix-user-chroot.git | ||
cd nix-user-chroot | $ cd nix-user-chroot | ||
make | $ make | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 89: | Line 89: | ||
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>: | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
mkdir -m 0755 ~/.nix | $ mkdir -m 0755 ~/.nix | ||
./nix-user-chroot/nix-user-chroot ~/.nix bash | $ ./nix-user-chroot/nix-user-chroot ~/.nix bash | ||
</syntaxHighlight> | </syntaxHighlight> | ||
This will start a new shell in which you can run the install script of nix: | This will start a new shell in which you can run the install script of nix: | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
curl https://nixos.org/nix/install | sh | $ curl https://nixos.org/nix/install | sh | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 108: | Line 108: | ||
The following commands will install nix the nix store to <code>~/.nix</code> | The following commands will install nix the nix store to <code>~/.nix</code> | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
chmod +x proot_5.1.1_x86_64_rc2--no-seccomp # first make sure the executable bit is set on the binary | $ chmod +x proot_5.1.1_x86_64_rc2--no-seccomp # first make sure the executable bit is set on the binary | ||
mkdir ~/.nix | $ mkdir ~/.nix | ||
./proot_5.1.1_x86_64_rc2--no-seccomp ~/.nix | $ ./proot_5.1.1_x86_64_rc2--no-seccomp ~/.nix | ||
</syntaxHighlight> | </syntaxHighlight> | ||
This will start a new shell, where nix can be installed: | This will start a new shell, where nix can be installed: | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
curl https://nixos.org/nix/install | sh | $ curl https://nixos.org/nix/install | sh | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 134: | Line 134: | ||
For example using <code>~/.xprofile</code> as follows: | For example using <code>~/.xprofile</code> as follows: | ||
<syntaxHighlight lang=" | <syntaxHighlight lang="console"> | ||
export XDG_DATA_DIRS=$HOME/.nix-profile/share:/usr/local/share:/usr/share | $ export XDG_DATA_DIRS=$HOME/.nix-profile/share:/usr/local/share:/usr/share | ||
</syntaxHighlight> | </syntaxHighlight> | ||