Nix Installation Guide
Oct 20, 2019

Nix package manager may be installed with or without root permissions. The root option is preferred since it provides a system-wide multiuser installation.

With root Permissions

The preferred (more general) installation with root permissions is the Multi User Installation. However, if you are the only user in your system, you can also follow Single User Installation guide. You may need in any case to login again into your system for your shell environment to have Nix tools available.

Please, follow these official guides to install Nix but also to uninstall it if no longer needed. There is also an official guide for Upgrading Nix.

Without root Permissions

Using the instructions of Installing without root permissions, as follows:

( # open a subshell
set -o errexit
set -o pipefail

echo "Confirming kernel user namespaces support ..."
unshare --user --pid echo YES
echo "Downloading nix-user-chroot ..."
read -r arch    < <(uname -m)
read -r version < <(
   wget \ \
      --output-document=/dev/null \
      --output-file=- \
   | grep Location \
   | sed 's|.*/tag/\(.*\) .*|\1|'
wget \
   $url/$version/nix-user-chroot-bin-$version-$(uname -m)-unknown-linux-musl \
chmod a+x nix-user-chroot
echo "Installing nix ..."
mkdir --mode=0755 --parents ~/.nix
./nix-user-chroot ~/.nix bash -c 'curl | sh'
echo "Installing nix-user-chroot ..."
mkdir --mode=0755 --parents ~/.nix/bin
mv nix-user-chroot ~/.nix/bin
echo 'PATH=$PATH:~/.nix/bin' >> ~/.profile

Reload current shell PATH with . ~/.profile or reopen consoles.

Note that you can only use Nix and the installed programs within the shell started by nix-user-chroot:

nix-user-chroot ~/.nix bash -l # login shell, which loads ~/.profile

You can uninstall Nix by simply executing the following line and removing ~/.nix directory:

sed -i '/^PATH=$PATH:~\/\.nix\/bin$/d' ~/.profile