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
# Check that curl is availablewhich curl || sudo apt install curl # Debian/UbuntuChoose 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.
| Criterion | Single-user | Multi-user |
|---|---|---|
| Daemon | No | Yes (nix-daemon) |
| Isolation | No privilege separation | Builds isolated in dedicated accounts |
| Users | Only one | Several |
| Recommended for | Quick tests, personal workstation | Servers, shared workstations, production |
| Rights needed to install | Current user | Root (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.
curl -fsSL -o install-nix.sh https://releases.nixos.org/nix/nix-2.35.2/installcurl -fsSL https://releases.nixos.org/nix/nix-2.35.2/install.sha256sha256sum install-nix.shless install-nix.shThe 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:
sh install-nix.sh --no-daemon- The installer downloads Nix and creates the
/nix/store/directory - It configures your shell by adding a loading line to
~/.profile - 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.
sh install-nix.sh --daemonThe installer asks a few questions. Answer yes each time to accept the defaults.
- The installer creates the
/nix/store/directory and the build accountsnixbld* - It installs and starts the service
nix-daemon.service, and writes/etc/nix/nix.conf - It creates
/etc/profile.d/nix.shand adds a loading line to the global shell files (/etc/bash.bashrcor/etc/bashrc,/etc/zshrc), so that every user has Nix in their PATH
After installation, check that the daemon is running:
systemctl status nix-daemon.serviceExpected 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:
nix --versionnix (Nix) 2.35.2Also check that the store is reachable through the daemon:
nix store infoStore URL: daemonVersion: 2.35.2Trusted: 0Store 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 itAdd the line to the /etc/nix/nix.conf file, after what the installer
wrote there (tee -a appends without overwriting):
echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.confThen restart the daemon:
sudo systemctl restart nix-daemon.serviceCheck that the configuration is taken into account:
nix config show experimental-featuresfetch-tree flakes nix-commandfetch-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:
# Load Nixif [ -e /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]; then . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.shfiFish
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.
# 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.fishendTest with a first temporary package
Let us check that Nix works end to end by running a package without installing it:
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:
which cowsay# cowsay not found: it is not in your PATHThis 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.
-
Stop the daemon:
Terminal window sudo systemctl stop nix-daemon.servicesudo systemctl disable nix-daemon.socket nix-daemon.servicesudo systemctl daemon-reload -
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/nixrm -rf ~/.nix-profile ~/.nix-defexpr ~/.nix-channels \~/.local/share/nix ~/.local/state/nix ~/.cache/nix -
Delete the accounts and the group:
Terminal window for i in $(seq 1 32); do sudo userdel "nixbld$i"; donesudo groupdel nixbld -
Remove the lines added by the installer to
/etc/bash.bashrc,/etc/bashrc,/etc/profile,/etc/zsh/zshrcand/etc/zshrc, depending on which ones exist on your distribution.
Single-user
rm -rf /nix ~/.nix-channels ~/.nix-defexpr ~/.nix-profile \ ~/.local/share/nix ~/.local/state/nix ~/.cache/nixAlso 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.
| Symptom | Likely cause | Solution |
|---|---|---|
nix: command not found after installation | Shell not reloaded | Open a new terminal or source the profile by hand |
error: getting status of /nix | /nix does not exist | Run the installer again |
error: cannot connect to daemon | nix-daemon stopped | sudo systemctl start nix-daemon.service |
error: experimental Nix feature 'nix-command' is disabled | Modern commands not enabled | Add experimental-features = nix-command flakes to /etc/nix/nix.conf |
permission denied on /nix/store/ | Single-user installation with the wrong owner | Check 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-commandandflakesin/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#cowsayto 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
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
Review
(0/0)Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Nix store, profiles and generations: understand the data model
A new full quiz with random questions
Work again only on the questions you missed