Auto Rollback
Revert machines to their pre-deploy generation automatically when activation fails.
When activation fails, the machine can be left with a new system profile generation that failed to fully activate. Auto rollback reverts the machine to the generation that was active before the deploy started (captured during the Inspect phase).
fleet: flakes: my-flake: installables: nixosConfigurations: webserver: auto_rollback: true # opt-in per installable machines: web-01:auto_rollback is a regular attribute: set it at fleet, flake, installable, or machine level, and it is inherited downward.
What happens on failure
Section titled “What happens on failure”- The activation fails (e.g.
switch-to-configurationexits non-zero after the profile was already switched). - Panix resolves the closure of the pre-deploy generation (the generation at Inspect time).
- It re-runs the activation against that closure, using the preset’s default activation mode and the
nix-env --profile --setstep before it, for types whose preset sets profiles (nixosConfigurations,darwinConfigurations,systemConfigs); profile-tracking types without profile-setting (homeConfigurations,nixOnDroidConfigurations) roll back the activation only.
The rollback is visible in the build logs as an explicit step after the failed activation, so it is clear which commands are a rollback and which generation is being restored:

The deploy still reports the original activation failure. The error notes whether auto rollback succeeded or failed, so a rolled-back deploy never looks like a successful one:
auto-rollback succeeded: activation failed: exit status 2When it does not run
Section titled “When it does not run”auto_rollbackis not set (or resolves to false) for the machine.- The activation mode is declared non-mutating by the installable’s preset. For NixOS that is only
dry-activate, which just prints what would happen. Custom output types can declare their own non-mutating modes viaactivation_non_mutating_modes. - The installable has no profile path (e.g.
packages, which install vianix profile addand have no generation concept). - No previous generation was found during Inspect (e.g. a fresh machine).
- The workflow was cancelled (a cancelled context would make the rollback commands fail instantly, burying the real activation error under rollback noise).
The test mode does trigger auto rollback on failure: it skips the profile switch but still activates the configuration (restarts services, sets up /etc), so a failed test can leave the machine running the broken config.
For bootstrapping a new machine there is no previous generation to restore, so auto rollback never applies to the bootstrap path.
To switch to an earlier generation explicitly, use the standalone panix rollback command, see Other Commands.
See the phase pipeline for how rollback fits into the deploy flow.