1
0
Fork 0
mirror of https://github.com/NixOS/nix.dev.git synced 2024-10-18 14:32:43 -04:00
nix.dev/source/tutorials/install-nix.md

85 lines
2 KiB
Markdown
Raw Normal View History

(install-nix)=
# Install Nix
## Linux
2022-12-04 03:16:32 -05:00
Install Nix via the recommended [multi-user installation]:
```shell-session
$ sh <(curl -L https://nixos.org/nix/install) --daemon
```
:::{note}
For security you may want to [verify the installation script] using GPG signatures.
:::
## macOS
2022-12-04 03:16:32 -05:00
Install Nix via the recommended [multi-user installation]:
```shell-session
$ sh <(curl -L https://nixos.org/nix/install)
```
:::{note}
For security you may want to [verify the installation script] using GPG signatures.
:::
## Windows (WSL2)
2022-12-04 03:16:32 -05:00
Install Nix via the recommended [single-user installation]:
```shell-session
$ sh <(curl -L https://nixos.org/nix/install) --no-daemon
```
2022-12-04 03:16:32 -05:00
However, if you have [systemd support] enabled, install Nix via the recommended [multi-user installation]:
```shell-session
$ sh <(curl -L https://nixos.org/nix/install) --daemon
```
:::{note}
For security you may want to [verify the installation script] using GPG signatures.
:::
2022-12-04 03:16:32 -05:00
[systemd support]: https://learn.microsoft.com/en-us/windows/wsl/wsl-config#systemd-support
## Docker
Start a Docker shell with Nix:
```shell-session
$ docker run -it nixos/nix
```
Or start a Docker shell with Nix exposing a `workdir` directory:
```shell-session
$ mkdir workdir
$ docker run -it -v $(pwd)/workdir:/workdir nixos/nix
```
2022-09-26 07:19:18 -04:00
The `workdir` example from above can be also used to start hacking on Nixpkgs:
```shell-session
$ git clone git@github.com:NixOS/nixpkgs
$ docker run -it -v $(pwd)/nixpkgs:/nixpkgs nixos/nix
bash-5.1# nix-build -I nixpkgs=/nixpkgs -A hello
bash-5.1# find ./result # this symlink points to the build package
```
## Verify installation
2022-09-26 07:19:18 -04:00
Check the installation by opening **a new terminal** and typing:
```shell-session
$ nix --version
nix (Nix) 2.11.0
```
2022-12-04 03:16:32 -05:00
[multi-user installation]: https://nixos.org/manual/nix/stable/installation/multi-user.html
[single-user installation]: https://nixos.org/manual/nix/stable/installation/single-user.html
[verify the installation script]: https://nixos.org/download.html#nix-verify-installation