Home Explore Blog Models CI



nix

doc/manual/source/installation/upgrading.md
dcc1fa356199934aa8b4bfd5bc045de8c52b81a3d8f8075a0000000300000591
# Upgrading Nix

> **Note**
>
> These upgrade instructions apply where Nix was installed following the [installation instructions in this manual](./index.md).

Check which Nix version will be installed, for example from one of the [release channels](http://channels.nixos.org/) such as `nixpkgs-unstable`:

```console
$ nix-shell -p nix -I nixpkgs=channel:nixpkgs-unstable --run "nix --version"
nix (Nix) 2.18.1
```

> **Warning**
>
> 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!
> Reverting to an older version of Nix may therefore require purging the store database before it can be used.

## Linux multi-user

```console
$ sudo su
# nix-env --install --file '<nixpkgs>' --attr nix cacert -I nixpkgs=channel:nixpkgs-unstable
# systemctl daemon-reload
# systemctl restart nix-daemon
```

## macOS multi-user

```console
$ sudo nix-env --install --file '<nixpkgs>' --attr nix cacert -I nixpkgs=channel:nixpkgs-unstable
$ sudo launchctl remove org.nixos.nix-daemon
$ sudo launchctl load /Library/LaunchDaemons/org.nixos.nix-daemon.plist
```

## Single-user all platforms

```console
$ nix-env --install --file '<nixpkgs>' --attr nix cacert -I nixpkgs=channel:nixpkgs-unstable
```

Chunks
50e315ce (1st chunk of `doc/manual/source/installation/upgrading.md`)
Title: Upgrading Nix: Multi-user and Single-user Environments
Summary
This document provides instructions for upgrading Nix, specifically for installations performed according to the manual's guide. It advises users to check the target Nix version beforehand and warns that upgrading may alter the local store database schema, potentially necessitating a database purge if reverting to an older Nix version. Detailed upgrade commands are provided for Linux multi-user, macOS multi-user, and single-user setups across all platforms, typically involving `nix-env` and restarting the Nix daemon or service.