Skip to content

feat(apply): magic rollback#133

Draft
water-sucks wants to merge 8 commits intonix-community:mainfrom
water-sucks:magic-rollback
Draft

feat(apply): magic rollback#133
water-sucks wants to merge 8 commits intonix-community:mainfrom
water-sucks:magic-rollback

Conversation

@water-sucks
Copy link
Collaborator

@water-sucks water-sucks commented Nov 14, 2025

Description

In case changes in configuration settings for connections (i.e. SSH, internet interfaces, etc.) restart and cause loss of access to the machine in question, this PR implements a magic rollback mechanism that runs on the target.

It offloads a ton of the switch logic into a supervisor bash script, which gets ran as a systemd-run transient unit on the host. What makes this hugely different from deploy-rs is that it does not require modifying the destination closure whatsoever, so magic rollback can be used on systems without nixos-cli WHATSOEVER, including on a completely base NixOS system with no extra options.

Closes #119.

@water-sucks water-sucks force-pushed the magic-rollback branch 5 times, most recently from a186653 to 42e7674 Compare November 22, 2025 12:42
@water-sucks water-sucks force-pushed the magic-rollback branch 3 times, most recently from e59057e to 6188280 Compare February 11, 2026 23:23
@nix-community nix-community deleted a comment from coderabbitai bot Feb 12, 2026
@water-sucks water-sucks force-pushed the magic-rollback branch 5 times, most recently from 6e5bcda to 6b0541f Compare February 20, 2026 10:08
@water-sucks water-sucks force-pushed the magic-rollback branch 5 times, most recently from 7f996e0 to c97de8f Compare March 2, 2026 00:16
Before, time spans were stored as a string, and parsed whenever a direct
time.Duration was needed. This is strange and requires manual
conversions, as compared to just using a new type for this and
implementing serialization/deserialization for the type directly so that
it can be used by both cobra and koanf as flag/config types.

This will also enable usage of systemd.time(7) spans in koanf configs,
with stronger validation as well.
shlex.Quote() is much more strict in escaping than my much more lax
utils.Quote() string. Using manual quoting allows passing multi-line
strings such as the supervisor script properly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apply: support magic rollback for remote machines

1 participant