Update nixos
To update Nixos you need to do two things :
- Update the channel
sudo nix-channel --update
- Apply updates
sudo nixos-rebuild switch
You can do step by step, or just do both in one command line :
nixos-rebuild switch --upgrade
You may reboot to apply major updates (ex : kernel updates).
To upgrade to a new major OS version, you need to add a channel and upgrade :
nix-channel --add https://channels.nixos.org/nixos-<version to upĝrade to ex: 25.05> nixos
sudo nixos-rebuild switch --upgrade
You can also do automatic upgrades by adding the following to your configuration.nix :
{
system.autoUpgrade.enable = true;
# Warning "allowReboot = true" allow the upgrade to reboot the machine in order to upgrade the kernel,
# if set to false it will stay in the current channel and only upgrade to last version in the current channel.
system.autoUpgrade.allowReboot = true;
}