Recovering from a bad NixOS rollback

Sometimes the previous generation is not the one you want.

List available generations

nixos-rebuild list-generations

Pick the generation number you trust, then switch to it.

Switch to a specific generation

sudo nixos-rebuild switch --generation 42

A table of common rescue paths

ProblemQuick path
Bad kernelBoot an older generation from the bootloader
Broken servicesystemctl stop unit then rollback
Lost secretsRestore from SOPS backups before activation

Remember

Rollbacks are only easy if you keep generations.

Set a reasonable configurationLimit on boot.loader.systemd-boot or GRUB so you do not erase your escape hatch.