tldr; switch-fix.nix lets you set an automatic rollback to current generation / profile on nixos-rebuild [switch | boot]
unless you cancel with cancel-rollback
from a terminal within a set amount of time
Ooh, nice.
GitHub - serokell/deploy-rs: A simple multi-profile Nix-flake deploy tool. does similar things for anyone interested, I still hope that it eventually gets local deployment as a first class citizen, until then this project seems like a cool alternative
Yup, I started with deploy-rs, liked it! The two issues I had were, switch
would sometimes not “stick”, in that on reboot, a previous generation would be default, and the auto rollback was sometimes iffy, either because of internet connection issues, or not possible (at least at the time) with boot
(instead of switch
).
This bit of bits was originally to address that first issue, and eventually the second.
Sorry maybe I’m misunderstanding but what does this do that nixos-rebuild test
doesn’t?
Two things I can think of:
nixos-rebuild test
won’t reboot into a previous generation if you’ve done something technically correct, nix config-wise, but functionally terrible (like, make your remote box inaccessible through bad network config). This is not too much of a problem in a cloud instance, you usually have access to some kind of KVM console where you can force reboot, but I’ve been in situations where I have a bare-metal server somewhere without technical people around to help me reboot.nixos-rebuilt test
by definition, as far as I know, can’t test the full reboot process. That is, there are config changes that require a reboot to fully test. This module allows you to donixos-rebuild boot
, reboot, and if you leave it alone without ssh’ing in andcancel-reboot
, it will roll back to the last (presumably) known good generation.
Or imagine you’ve deployed NixOS to a satellite and there somehow was a detail different in staging
Some providers also charge for rescue shell access in some configurations.
Ok that’s a better example. I have to imagine they had all sort of failsafes for that situation, like a/b boot configs similar to phones. Hmmmmm… nixos-a-b-boot…