Updated: 2 November 2026 · Applies to: Nix 2.35.4 (single-user install tested on Debian 13 and Ubuntu 24.04, x86_64); multi-user install according to the Nix manual

Nix is a package manager that installs every package into its own folder under /nix/store, so installing or upgrading one package cannot break another, several versions can live side by side, and every change can be rolled back. It runs on any Linux distribution next to apt or dnf, without replacing them. To install it on a server, run the official installer from nixos.org, then use nix-env -iA nixpkgs.NAME to install a package, nix-env -q to list, nix-env -uA nixpkgs.NAME to upgrade and nix-env -e NAME to remove.

What Nix is, in short

  • Isolated store: each package lives in a path such as /nix/store/pa6rydwgjxxmmvdxap7qk9c85h8jbimy-hello-2.12.3. The hash in the name covers the package and all its dependencies.
  • Profiles and generations: what you "install" is a set of links in your profile (~/.nix-profile). Every change creates a new generation, and you can switch back to an older one.
  • Per-user packages: normal users can install software without root, and a package already in the store is not downloaded twice.
  • Nixpkgs: the package collection, delivered through a channel (by default nixpkgs-unstable) with prebuilt binaries from cache.nixos.org.
  • Licence: Nix is free software under the LGPL 2.1. NixOS is the Linux distribution built around it, but you do not need NixOS to use Nix.

Single-user or multi-user install?

According to the Nix manual, multi-user is the recommended option on Linux when the system runs systemd, SELinux is disabled and you can use sudo. It runs a nix-daemon service and builds as separate nixbld users, which gives better isolation and lets users share builds. Single-user is simpler: the whole /nix folder belongs to one user and there is no daemon. The manual suggests it for systems without systemd. On AlmaLinux or Rocky, check getenforce first: SELinux is usually enforcing there.

Step 1: install the tools the installer needs

The installer is a shell script that downloads a .tar.xz archive, so it needs curl and xz. On Debian and Ubuntu:

sudo apt update
sudo apt install -y curl xz-utils

Run the installer as your normal user, not as root. It calls sudo when it needs to create /nix.

Step 2a: multi-user install (systemd servers)

This is the command published on the Nix download page. We did not run it in our test containers because it needs systemd as the init system:

curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --daemon

According to the Nix manual, it creates the nixbld group and build users, installs and starts the nix-daemon systemd service, and adds Nix to the system shell profiles. Open a new shell when it finishes.

Step 2b: single-user install (tested)

curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --no-daemon

Output (shortened, Debian 13):

downloading Nix 2.35.4 binary tarball for x86_64-linux from 'https://releases.nixos.org/nix/nix-2.35.4/nix-2.35.4-x86_64-linux.tar.xz' ...
performing a single-user installation of Nix...
directory /nix does not exist; creating it by running 'mkdir -m 0755 /nix && chown alice /nix' using sudo
copying Nix to /nix/store...
installing 'nix-2.35.4'
unpacking 1 channels...
modifying /home/alice/.profile...

Installation finished!

Load Nix into the current shell (new logins do this by themselves through ~/.profile):

. ~/.nix-profile/etc/profile.d/nix.sh

Check the version and the channel:

nix --version
nix-channel --list

Output:

nix (Nix) 2.35.4
nixpkgs https://channels.nixos.org/nixpkgs-unstable

In a container you may also see "warning: auto-disabling sandboxing because the prerequisite namespaces are not available". That came from our container test, which blocks the namespaces Nix uses for its build sandbox; installing binary packages still worked.

Step 3: install, list, upgrade and remove packages

The classic command is nix-env. Always select packages by attribute path with -A (for example nixpkgs.hello): the Nix manual says this is much faster and never ambiguous. To find a package's attribute name, search on search.nixos.org.

Install a package:

nix-env -iA nixpkgs.hello

Output:

installing 'hello-2.12.3'
these 5 paths will be fetched (11.0 MiB download, 36.7 MiB unpacked):
  /nix/store/pqyiidz5mi73wv5f91d48s9plcqyj5bz-glibc-2.44-57
  /nix/store/pa6rydwgjxxmmvdxap7qk9c85h8jbimy-hello-2.12.3
  ...
building '/nix/store/r4hqja6bijfi2cwwwhahsp04s0qwwvd7-user-environment.drv'...

The command in your PATH is a link into the store:

readlink -f "$(command -v hello)"

Output:

/nix/store/pa6rydwgjxxmmvdxap7qk9c85h8jbimy-hello-2.12.3/bin/hello

List installed packages:

nix-env -q

Output:

hello-2.12.3
nix-2.35.4
tree-2.3.2

Refresh the channel (similar to apt update), then upgrade one package:

nix-channel --update
nix-env -uA nixpkgs.hello

Remove a package:

nix-env -e tree

Removing only takes the package out of your profile; the files stay in the store until garbage collection, which is what makes a rollback possible.

Avoid the name-based forms on small servers. nix-env -qa (list everything available) and a plain nix-env -u (upgrade all by name) evaluate the whole of Nixpkgs. In our lab container on a small test VPS, nix-env -qa grew past 3 GB of memory and had not finished after more than 10 minutes, so we stopped it; plain nix-env -u passed 1.4 GB before we stopped it too. Use -A with named packages instead, or add swap first (see How to Create a Swap File in Linux).

Step 4: generations, rollback and garbage collection

nix-env --list-generations

Output:

   1   2026-11-02 15:29:39
   2   2026-11-02 15:37:32
   3   2026-11-02 15:37:44   (current)

Undo the last change (here, it brought back the removed tree package):

nix-env --rollback

Output:

switching profile from version 4 to 3

Delete old generations and free unused store paths. After this, you can no longer roll back to the deleted generations:

nix-collect-garbage -d

Output (end):

1717 store paths deleted, 447.5 MiB freed

Try a tool without installing it

nix-shell -p opens a temporary shell with a package available and leaves your profile untouched:

nix-shell -p cowsay --run "cowsay hi"

nix-env or nix profile and flakes?

Newer Nix also has the nix command (nix profile install, nix run, nix search) and flakes. According to the Nix manual, nix-command and flakes are still experimental features in Nix 2.35, and nix profile says "This program is experimental and its interface is subject to change". They are off by default; without them we got:

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

To turn them on for your user, add this line to ~/.config/nix/nix.conf:

experimental-features = nix-command flakes

Then, for example, run a package once without installing it:

nix run nixpkgs#hello

Which to use: for a server you want to keep stable, nix-env with -A is the documented, non-experimental path and is what this guide uses. Many community guides use flakes and nix profile, and they work, but their interface can still change. Do not mix the two on one profile: the Nix manual warns that once you have used nix profile, nix-env no longer works on that profile until you delete it (and the packages in it).

How to uninstall Nix

Single-user (tested): store files are read-only, and /nix sits in the root folder, so a plain rm -rf /nix as your user fails with "Permission denied". Remove it with sudo, then delete your own Nix files:

sudo rm -rf /nix
rm -rf ~/.nix-channels ~/.nix-defexpr ~/.nix-profile ~/.local/share/nix ~/.local/state/nix ~/.cache/nix

Finally, delete the line ending in "added by Nix installer" from ~/.profile.

Multi-user (according to the Nix manual): stop the daemon first:

sudo systemctl stop nix-daemon.service
sudo systemctl disable nix-daemon.socket nix-daemon.service
sudo systemctl daemon-reload

Remove the files:

sudo rm -rf /etc/nix /etc/profile.d/nix.sh /etc/tmpfiles.d/nix-daemon.conf /nix ~/.local/share/nix ~/.local/state/nix ~/.cache/nix ~/.nix-defexpr ~/.nix-profile ~/.nix-channels ~root/.nix-channels ~root/.nix-defexpr ~root/.nix-profile ~root/.cache/nix

Remove the build users and their group:

for i in $(seq 1 32); do sudo userdel nixbld$i; done
sudo groupdel nixbld

Then remove any Nix lines from /etc/bash.bashrc, /etc/bashrc, /etc/profile, /etc/zsh/zshrc and /etc/zshrc.

Official documentation: the Nix reference manual (installation, nix-env and experimental features) and the Nix download page. Source code: NixOS/nix on GitHub.

Want a server to try Nix on? A Ucartz KVM VPS gives you full root access on a systemd distribution, which is what the multi-user install needs.

Was this answer helpful?

Still stuck? Open a ticket