NixOS 23.10
How to upgrade the NixOS 23.11 to NixOS 24.05?
Upgrade your old NixOS to the new NixOS.
Recently, NixOS released a new version, 23.11 ("Tapir"). Switching the old version to the latest version in NixOS is a very easy process.
You need to copy and paste two commands in the terminal one by one to upgrade the NixOS.
I installed NixOS with Gnome, and you aren't wary; even if you use plasma-desktop and Nix, it works fine for you.
The upgrade of the NixOS is based on the channel. When You change or switch channels from one version to a second, that means you upgrade the NixOS.
The nix-channel command helps to add or remove a new channel in NixOS. You can even check the exciting channel list using the --list
option.
nix-channel --list
nixos https://channels.nixos.org/nixos-23.11
unstable https://channels.nixos.org/nixos-unstable
home-manager https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz
You can combine nix-channel with the grep command to list all exciting channels related to NixOS.
nix-channel --list | grep nixos
nixos https://channels.nixos.org/nixos-unstable
There are two ways to upgrade the NixOS 23.05 to NixOS 23.10. Even if you upgrade the NixOS version or demote switch back to the old NixOS build version, the following method will work for you.
Method
- User-based (non-root user or without sudo)
- Root User (with sudo)
User-based (non-root user or without sudo)
You use NixOS as a user; you install or remove packages using the home manager, You do not have root privilege. The user-based method is helpful for the remote server.
In NixOS, You can easily switch from NixOS 23.05 to NixOS 23.10. First, add a new NixOS 23.10 channel in your NixOS using the nix-channel command.
nix-channel --add https://channels.nixos.org/nixos-24.05 nixos
After rebuilding your system using the nixos-rebuild command.
sudo nixos-rebuild switch --upgrade
Following the nixos-rebuild command takes time based on the internet connection and your hardware.
Most important, When you use the User-based (non-root user or without sudo) method.
- It cannot upgrade the operating system like the gnome or plasma version. It only updates the packages like Chrome, Firefox, git, etc.
- It cannot change the
/etc/nixos/configuration.nix
file.
Root User (with sudo)
I used NixOS as my primary operating system in my laptop, To update the full NixOS in your machine.
You have a root privilege; first, add a new NixOS 23.10 channel or any channel using the nix-channel command with sudo privilege.
sudo nix-channel --add https://channels.nixos.org/nixos-24.05 nixos
Lastly, rebuild your system with the following command.
sudo nixos-rebuild switch --upgrade
The nixos-rebuild command takes some time, and it depends on your internet connection and your machine. Usually, it takes 15 to 20 minutes.
After rebuilding your system, restart your laptop or machine. Root User updates your packages (chrome, git), changes in /etc/nixos/configuration.nix
file and operating system, in my case, it is Gnome (Gnome 44.1 to 45.1).
To verify whether your system is upgraded or not, use the nix-info and gnome-shell command. The nix-info command tells you the system, version and channel information based on the user.
nix-info
system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.18.1, channels(officialrajdeepsingh): "home-manager-23.05.tar.gz, nixos-23.11", channels(root): "nixos-23.11", nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
gnome-shell --version
GNOME Shell 45.1
With both User-based (non-root user or without sudo) and Root User (with sudo) methods, it can not upgrade your home manager version. To update the home manager, you separately upgrade it.
Conclusion
Upgrading and demoting or switching NixOS from one version to another. You can do it with two commands.
The best part of using NixOS is that NixOS only switches update versions if the NixOS build is successful. Otherwise, it is switched back to the old build.
You can share and follow me on Twitter and LinkedIn. I write tons of articles related to front-end development and Linux.
If you are interested in those topics, follow me on Medium, officialrajdeepsingh.dev, join the Linux and front-end web publication, and sign up for my free newsletter.