Linux
Multi-user installation (recommended)
Install Nix via the
recommended
multi-user installation:
$ sh <(curl -L https://nixos.org/nix/install) --daemon
We recommend the multi-user install if you are on Linux running systemd, with SELinux disabled and
you can authenticate with sudo
.
Single-user installation
Install Nix via the
single-user installation:
$ sh <(curl -L https://nixos.org/nix/install) --no-daemon
Above command will perform a single-user installation of Nix, meaning
that /nix
is owned by the invoking user. You should run
this under your usual user account, not as root
. The
script will invoke sudo
to create /nix
if
it doesn’t already exist.
Which type of installation should you choose?
This depends on your requirements, but here is a short list of
reasons why we recommend
multi-user installation:
Pros
- Better build isolation (and that is what Nix is all about)
- Better security (a build can not write somewhere in your home)
- Sharing builds between users
Cons
- Requires
root
to run the daemon
- More involved installation (creation of
nixbld* users
, installing a systemd unit, ...
- Harder to uninstall
MacOS
Multi-user installation
Install Nix via the
recommended
multi-user installation:
$ sh <(curl -L https://nixos.org/nix/install)
We believe we have ironed out how to cleanly support the read-only
root on modern macOS. Please
consult the manual
on details what the installation script does.
Windows (WSL2)
Single-user installation
Install Nix via the
single-user installation:
$ sh <(curl -L https://nixos.org/nix/install) --no-daemon
Docker
Start a Docker shell with Nix:
$ docker run -it nixos/nix
Or start a Docker shell with Nix exposing a workdir
directory:
$ mkdir workdir
$ docker run -it -v $(pwd)/workdir:/workdir nixos/nix
The workdir
example from above can be also used to start hacking on nixpkgs:
$ git clone git@github.com:NixOS/nixpkgs
$ docker run -it -v $(pwd)/nixpkgs:/nixpkgs nixos/nix
docker> nix-build -I nixpkgs=/nixpkgs -A hello
docker> find ./result # this symlink points to the build package
Verify installation
Check the installation by opening
a new terminal and typing:
$ nix-env --version
nix-env (Nix) 2.3.15
You may want to verify the
integrity of the installation script
using GPG:
$ curl -o install-nix-2.8.1 https://releases.nixos.org/nix/nix-2.8.1/install
$ curl -o install-nix-2.8.1.asc https://releases.nixos.org/nix/nix-2.8.1/install.asc
$ gpg2 --keyserver hkps://keyserver.ubuntu.com --recv-keys B541D55301270E0BCF15CA5D8170B4726D7198DE
$ gpg2 --verify ./install-nix-2.8.1.asc
$ sh ./install-nix-2.8.1
The signing key has fingerprint
B541 D553 0127 0E0B CF15 CA5D 8170 B472 6D71 98DE
.
It is also available
on GitHub.
More ...
The following release items are also available: