YOUR JOURNEY
10 / 18
02THE NIXOS SYSTEM 6 MIN READ
LESSON 10 / GENERATIONS & ROLLBACKS

Move forward.
Keep a way back.

A system update selects a new generation, while the old one can remain.

Rollback changes which configuration is selected. It does not rewind your documents or undo a database migration.

Explore the lesson
~$ NixOS examples · try them in a VM.
SYSTEM GENERATIONS01 / 03
Drag to rotate

The profile selects the currently active generation.

Generation 2 selected
10.1RETURN TO A KNOWN CONFIGURATION

Keep an escape route.

If the new configuration misbehaves but your machine is still usable, switch to the previous retained generation with the command below. You can also select an older NixOS generation in the boot menu when available.

A rollback changes the system profile and activates that configuration. Your configuration source files are not automatically reverted; restore the intended version in Git before rebuilding, or you may recreate the unwanted change.

terminal · NixOS only
sudo nixos-rebuild switch --rollback
 
# Inspect the current system target:
readlink -f /run/current-system
Next section: Garbage collection follows references.
10.2RETENTION MATTERS

Garbage collection follows references.

Nix retains store objects that are reachable from garbage-collection roots, including retained profiles and generations. Unreferenced objects can be collected. Deleting generations removes recovery choices.

Do not manually remove files from /nix/store. Choose a retention policy deliberately, and remember that rolling back system packages does not reverse changes to mutable service data. Keep backups independently.

TAKE THIS WITH YOU

A rollback selects an old configuration, not an old copy of all disk state.

Go a little deeperNixOS system configuration
UP NEXT

Packages, users & services

Having a binary and running a service are two different requests.

Next lesson