Skip to content
Français
Account: not signed in, sync available My learning
Select theme
Français

Install Nix on Linux: single-user and multi-user mode

By updated

Improve this page

Installing Nix takes less than 5 minutes and puts most of its files in the /nix directory. You can install it on Debian, Ubuntu, Fedora, Arch or any Linux distribution, and uninstall it cleanly if needed. This guide covers the two installation modes, the initial setup of the modern commands and flakes, and a first test to check that everything works. The outputs shown were captured on Nix 2.35.2.

What you will learn

  • Choose between the single-user and multi-user installation for your context
  • Install Nix on your Linux distribution with an installer checked against its hash
  • Enable the modern commands (nix shell, nix profile, nix search) and flakes
  • Check that the installation works with a first temporary package
  • Uninstall Nix cleanly if needed

In what context?

You have read the guide on the Nix ecosystem and want to get hands-on. Here are the typical situations:

  • You run a Debian or Ubuntu server and want to try Nix without touching your existing apt installation.
  • You work on several projects that need different versions of Python, Node.js or Terraform.
  • You are preparing a reproducible environment for your team.
  • You are on a shared workstation and need to isolate your packages.

Prerequisites

  • A Linux system with root access (sudo)
  • curl installed (present by default on most distributions)
  • At least 5 GB of free disk space for /nix
  • An Internet connection
Terminal window
# Check that curl is available
which curl || sudo apt install curl # Debian/Ubuntu

Choose between single-user and multi-user

Nix offers two installation modes, and the choice depends on your usage. The deciding criterion is privilege separation: in multi-user mode, a daemon builds packages under dedicated accounts, which protects the store from the other users of the machine.

CriterionSingle-userMulti-user
DaemonNoYes (nix-daemon)
IsolationNo privilege separationBuilds isolated in dedicated accounts
UsersOnly oneSeveral
Recommended forQuick tests, personal workstationServers, shared workstations, production
Rights needed to installCurrent userRoot (for the daemon)

Download and check the installer

The nixos.org download page suggests piping the installation script into sh. Do not: you would run as root a script nobody has read, without knowing which version it installs. For each version, the project publishes the script and its SHA-256 hash on releases.nixos.org: download both, compare, read the script, and only then run it.

Terminal window
curl -fsSL -o install-nix.sh https://releases.nixos.org/nix/nix-2.35.2/install
curl -fsSL https://releases.nixos.org/nix/nix-2.35.2/install.sha256
sha256sum install-nix.sh
less install-nix.sh

The two hashes must match, measured on 1 October 2026: 9adda97297d9e8ab360df95c729eabff4f4f93d6db091953c3a68f29e3fb130c. The script in turn pins the Nix 2.35.2 archive of each architecture by its hash, and refuses an archive that does not match it.

Install Nix in single-user mode

Single-user mode is the simplest. Nix installs into /nix and runs directly under your user, without a daemon. Run the checked script with the --no-daemon option:

Terminal window
sh install-nix.sh --no-daemon
  1. The installer downloads Nix and creates the /nix/store/ directory
  2. It configures your shell by adding a loading line to ~/.profile
  3. The Nix commands become available in your PATH

Install Nix in multi-user mode

Multi-user mode creates a system daemon (nix-daemon) and a group of dedicated accounts (nixbld1 to nixbld32) to isolate builds. Unlike single-user mode, it also touches a few system files outside /nix, which uninstalling will have to remove.

Terminal window
sh install-nix.sh --daemon

The installer asks a few questions. Answer yes each time to accept the defaults.

  1. The installer creates the /nix/store/ directory and the build accounts nixbld*
  2. It installs and starts the service nix-daemon.service, and writes /etc/nix/nix.conf
  3. It creates /etc/profile.d/nix.sh and adds a loading line to the global shell files (/etc/bash.bashrc or /etc/bashrc, /etc/zshrc), so that every user has Nix in their PATH

After installation, check that the daemon is running:

Terminal window
systemctl status nix-daemon.service

Expected output:

● nix-daemon.service - Nix Daemon
Loaded: loaded (/etc/systemd/system/nix-daemon.service; linked; preset: enabled)
Active: active (running)
Main PID: 2383 (nix-daemon)

Alternative: the Determinate Nix Installer

The Determinate Nix Installer, maintained by the company Determinate Systems, is an alternative to the official installer. It always installs in multi-user mode, enables flakes by default, and provides a one-command uninstall (/nix/nix-installer uninstall). Its documentation, too, suggests piping a script into sh: the same rule applies, you download, read, then run.

Check the installation

Open a new terminal (or source the profile by hand) and test:

Terminal window
nix --version
nix (Nix) 2.35.2

Also check that the store is reachable through the daemon:

Terminal window
nix store info
Store URL: daemon
Version: 2.35.2
Trusted: 0

Store URL: daemon confirms that your command does go through the daemon. The Trusted line tells whether your account is listed in trusted-users, which is root by default: an ordinary user therefore reads Trusted: 0, and that is normal. Only root (or an account added to trusted-users) reads Trusted: 1, which allows sensitive settings such as adding a binary cache.

Enable the modern commands and flakes

By default, the modern commands (nix shell, nix profile, nix search, nix develop) and flakes are disabled, because the Nix team still considers them experimental, even though the community uses them heavily. On Nix 2.35.2, the slightest of these commands fails until the feature is enabled:

error: experimental Nix feature 'nix-command' is disabled; add '--extra-experimental-features nix-command' to enable it

Add the line to the /etc/nix/nix.conf file, after what the installer wrote there (tee -a appends without overwriting):

Terminal window
echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.conf

Then restart the daemon:

Terminal window
sudo systemctl restart nix-daemon.service

Check that the configuration is taken into account:

Terminal window
nix config show experimental-features
fetch-tree flakes nix-command

fetch-tree appears on its own: it is a feature that flakes depend on, enabled automatically along with them. There is no need, on the other hand, to write sandbox = true: the build sandbox is already active by default on Linux.

Configure your shell

Bash and Zsh

In multi-user mode, the installer adds the Nix loading line to the global shell files, read when a session opens. If the Nix commands are not available after logging in, add the loading of the daemon script to your ~/.bashrc or ~/.zshrc:

Terminal window
# Load Nix
if [ -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
fi

Fish

For Fish, add to ~/.config/fish/config.fish the script that matches your installation mode: nix-daemon.fish in multi-user mode, nix.fish in single-user mode.

Terminal window
# Load Nix (multi-user installation)
if test -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.fish
end

Test with a first temporary package

Let us check that Nix works end to end by running a package without installing it:

Terminal window
nix run nixpkgs#cowsay -- 'Nix works!'

The first run downloads the dependencies from the binary cache:

____________
< Nix works! >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||

The cowsay package is not installed in your profile. It was downloaded into the store (/nix/store/) and run only once. You can check it:

Terminal window
which cowsay
# cowsay not found: it is not in your PATH

This is one of the strengths of Nix: trying a tool in one command, without polluting your system.

Uninstall Nix cleanly

If you want to remove Nix from your system, follow the procedure of the Nix manual for your installation mode. The multi-user version has more steps, because the installer touched system files and created accounts.

Multi-user

The four steps follow the order of the manual: stop the daemon, delete the files, remove the build accounts, then clean the global shell files. Skip the last one and every new shell will print an error while looking for a script that no longer exists.

  1. Stop the daemon:

    Terminal window
    sudo systemctl stop nix-daemon.service
    sudo systemctl disable nix-daemon.socket nix-daemon.service
    sudo systemctl daemon-reload
  2. Delete the Nix files, those of your account and those of root:

    Terminal window
    sudo rm -rf /etc/nix /etc/profile.d/nix.sh /etc/tmpfiles.d/nix-daemon.conf /nix \
    ~root/.nix-channels ~root/.nix-defexpr ~root/.nix-profile ~root/.cache/nix
    rm -rf ~/.nix-profile ~/.nix-defexpr ~/.nix-channels \
    ~/.local/share/nix ~/.local/state/nix ~/.cache/nix
  3. Delete the accounts and the group:

    Terminal window
    for i in $(seq 1 32); do sudo userdel "nixbld$i"; done
    sudo groupdel nixbld
  4. Remove the lines added by the installer to /etc/bash.bashrc, /etc/bashrc, /etc/profile, /etc/zsh/zshrc and /etc/zshrc, depending on which ones exist on your distribution.

Single-user

Terminal window
rm -rf /nix ~/.nix-channels ~/.nix-defexpr ~/.nix-profile \
~/.local/share/nix ~/.local/state/nix ~/.cache/nix

Also remove the loading line added to ~/.profile.

Troubleshooting

Most blockers come down to a shell that has not loaded Nix yet, a stopped daemon, or experimental features that are not enabled. Read the exact message: the one in the fourth row names the missing option itself.

SymptomLikely causeSolution
nix: command not found after installationShell not reloadedOpen a new terminal or source the profile by hand
error: getting status of /nix/nix does not existRun the installer again
error: cannot connect to daemonnix-daemon stoppedsudo systemctl start nix-daemon.service
error: experimental Nix feature 'nix-command' is disabledModern commands not enabledAdd experimental-features = nix-command flakes to /etc/nix/nix.conf
permission denied on /nix/store/Single-user installation with the wrong ownerCheck ls -ld /nix/store, the owner must be your user (single) or root (multi)

Key points

  • Multi-user mode is recommended: it isolates builds in dedicated accounts and works for every user of the system.
  • Enable nix-command and flakes in /etc/nix/nix.conf, it is essential to follow the guides of this section.
  • Nix leaves your packages alone: apt, dnf and what they installed stay intact, Nix packages live in /nix.
  • Test with nix run nixpkgs#cowsay to check that everything works end to end.
  • Uninstalling a multi-user setup takes four steps: daemon, files, nixbld* accounts, then global shell files.

Knowledge check

Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer

Is this project useful to you?

The guides, courses, quizzes and labs stay free. If you use them regularly, you can contribute to their upkeep and development.

Become a supporting member (new tab) One-time support (new tab) Learn more

Follow the project on LinkedIn