Is it necessary to update the channel before rebuild switch?

NixOS 23.11 manual | Nix & NixOS says

Packages come from the NixOS channel. You typically upgrade a package
by updating to the latest version of the NixOS channel:

$ nix-channel --update nixos

and then running nix-env -i again. Other packages in the profile are
not affected; this is the crucial difference with the declarative
style of package management, where running nixos-rebuild switch
causes all packages to be updated to their current versions in the
NixOS channel.

On NixOS, before running

sudo nixos-rebuild switch

is it necessary to update the channel by

nix-channel update nixos

?

Or will the switch command do the channel update by itself?

1 Like

It will not, by default. You can use the --upgrade or --upgrade-all flags to make it first update channels though.

Also - given this is asked so soon after the 23.11 release - note none of these commands change the channel, so if you’re using 23.05 you will not upgrade to 23.11. You need to change the channel URL for that.

3 Likes