How to update and upgrade NixOS
Introduction
I’ve recently set up NixOS and have it running smoothly, including the configuration and transition to Podman. I’ve compiled this note on how to update and upgrade NixOS.
How To
Configuration update
The following command will rebuild the system, activate the new generation immediately and make it the default boot option:
To revert the changes, you can use the following command:
System update
With the --upgrade
option you can update the NixOS channel of the root user before building the configuration:
Release upgrade
Before proceeding with a system upgrade, it’s crucial to review the release notes of the most recent version. These notes often contain important instructions and steps that need to be followed to ensure a smooth and successful upgrade process.
You can check the current NixOS channel with the following command:
Add the channel of the new release:
Instructions:
- Required Replace
VERSION
with the new version for example24.11
Then update the channel en upgrade the system:
Cleaning up
As outlined here, it’s important to periodically remove unused packages by running the Nix garbage collector. This tool will clear out any packages in the Nix store that are not being used, either directly or indirectly, by any current profile generation.
Keep in mind that packages referenced by older generations won’t be deleted since the system needs them to enable rollbacks. Therefore, for garbage collection to be truly effective, you should also consider deleting some of the older generations. Naturally, you should only do this if you’re confident that you won’t need to perform any rollbacks.
No comments found for this note.
Join the discussion for this note on Github. Comments appear on this page instantly.