How do I make sure that all packages I install on my system nixos installation (i.e. packages listed in /etc/nixos/configuration.nix
, which I install using sudo nixos-rebuild switch
) are using the latest (unstable) version of nixos/nixpkgs?
Asked
Active
Viewed 2.9k times
31

sid-kap
- 941
- 1
- 10
- 17
-
you can also choose to get individual packages from unstable and the rest from a stable channel – Andrew Aug 05 '23 at 22:40
2 Answers
46
As explained in the manual's section on upgrading, if you issue the following command as root:
# nix-channel --list
you will most likely see something like the following (if you were following the 16.09 branch for instance):
nixos https://nixos.org/channels/nixos-16.09
By issuing the following command (still as root):
# nix-channel --add https://nixos.org/channels/nixos-unstable nixos
you will remove the 16.09 channel and replace it with nixos-unstable.
Now this is not enough yet. To really update your system, you need one last command:
# nixos-rebuild switch --upgrade
which is going to rebuild your system with your current configuration and updated packages from the channel you switched to.

Arnout Engelen
- 6,709
- 1
- 25
- 36

Zimm i48
- 2,901
- 17
- 26
-
This actually didn't work for me. As @sid-kap said, you really need the `sudo`. – haffla Feb 15 '18 at 19:36
-
6
-
1update your channel before rebuilding or it won't have any effect `sudo nix-channel --update` – 0x6C38 May 27 '18 at 21:27
-
1The `--upgrade` option is meant to perform the `--update` so when using exactly the commands that I indicated, it should work fine. – Zimm i48 Jun 05 '18 at 13:17
-
3I had to run `sudo nix-channel --update` first, otherwise `sudo nixos-rebuild switch --upgrade` gives me me an error: `error: reading symbolic link '/nix/var/nix/profiles/per-user/root/channels/nixos-unstable': No such file or directory` – Jay Sullivan Jun 05 '22 at 23:34
6
Run the following commands:
sudo nix-channel --add https://nixos.org/channels/nixos-unstable
sudo nix-channel --add https://nixos.org/channels/nixpkgs-unstable
Note that the sudo
is required: if you don't use sudo
, it will only affect user-level packages (i.e. things you install using nix-env -i
), not system-level packages.

Jan Tojnar
- 5,306
- 3
- 29
- 49

sid-kap
- 941
- 1
- 10
- 17
-
2
-
I think one is for the core Nixos operating system, the other is for the additional software you install. – sid-kap Jan 25 '18 at 22:44
-
2nixos is typically package set for NixOS, nixpkgs is package set when you have nix installed as package manager on non NixOS distro. They are built from the same repo. https://hydra.nixos.org/jobset/nixos/release-19.03#tabs-configuration https://hydra.nixos.org/jobset/nixpkgs/nixpkgs-19.03-darwin#tabs-configuration – spinus Jun 16 '19 at 10:18
-
There's some more info here about difference between the channels: https://discourse.nixos.org/t/differences-between-nix-channels/13998 – entropo Sep 13 '21 at 06:02