2020-07-23 00:17:48 +03:00
# Upgrading Nix
2024-01-06 20:01:10 +02:00
> **Note**
>
2024-01-07 00:44:15 +02:00
> These upgrade instructions apply where Nix was installed following the [installation instructions in this manual](./index.md).
2024-01-06 20:01:10 +02:00
2024-01-07 00:44:15 +02:00
Check which Nix version will be installed, for example from one of the [release channels ](http://channels.nixos.org/ ) such as `nixpkgs-unstable` :
2024-01-06 20:01:10 +02:00
```console
2024-01-07 00:44:15 +02:00
$ nix-shell -p nix -I nixpkgs=channel:nixpkgs-unstable --run "nix --version"
2024-01-06 20:01:10 +02:00
nix (Nix) 2.18.1
```
> **Warning**
>
2024-01-07 00:44:15 +02:00
> Writing to the [local store](@docroot@/store/types/local-store.md) with a newer version of Nix, for example by building derivations with [`nix-build`](@docroot@/command-ref/nix-build.md) or [`nix-store --realise`](@docroot@/command-ref/nix-store/realise.md), may change the database schema!
2024-01-06 20:01:10 +02:00
> Reverting to an older version of Nix may therefore require purging the store database before it can be used.
2024-01-07 00:44:15 +02:00
### Linux multi-user
2024-01-06 20:01:10 +02:00
```console
2024-01-07 00:44:15 +02:00
$ sudo su
# nix-env --install --file '<nixpkgs>' --attr nix cacert -I nixpkgs=channel:nixpkgs-unstable
# systemctl daemon-reload
# systemctl restart nix-daemon
2024-01-06 20:01:10 +02:00
```
2024-01-07 00:44:15 +02:00
## macOS multi-user
```console
$ sudo nix-env --install --file '< nixpkgs > ' --attr nix -I nixpkgs=channel:nixpkgs-unstable
$ sudo launchctl remove org.nixos.nix-daemon
$ sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
```
2020-07-23 00:17:48 +03:00
2024-01-07 00:44:15 +02:00
## Single-user all platforms
2020-07-23 00:17:48 +03:00
2024-01-07 00:44:15 +02:00
```console
$ nix-env --install --file '< nixpkgs > ' --attr nix cacert -I nixpkgs=channel:nixpkgs-unstable
```