difftreelog
feat more resilent rollback service
in: trunk
1 file changed
nixos/rollback.nixdiffbeforeafterboth667 systemd.services.rollback-watchdog = {7 systemd.services.rollback-watchdog = {8 description = "Rollback watchdog";8 description = "Rollback watchdog";9 script = ''9 script = ''10 set -eu10 set -eux11 if [ -f /etc/fleet_rollback_marker ]; then11 if [ -f /etc/fleet_rollback_marker ]; then12 echo "found the rollback marker, switching to older generation"12 echo "found the rollback marker, switching to older generation"13 target=$(cat /etc/fleet_rollback_marker)13 target=$(cat /etc/fleet_rollback_marker)14 echo "rolling back profile"14 echo "rolling back profile"15 nix profile rollback --profile /nix/var/nix/profiles/system --to "$target"15 nix profile rollback --profile /nix/var/nix/profiles/system --to "$target"16 echo "executing activation script"16 echo "executing activation script"17 "/nix/var/nix/profiles/system-$target-link/bin/switch-to-configuration" switch17 "/nix/var/nix/profiles/system-$target-link/bin/switch-to-configuration" switch || true18 echo "removing rollback marker"18 echo "removing rollback marker"19 rm -f /etc/fleet_rollback_marker19 rm -f /etc/fleet_rollback_marker20 else20 else21 echo "rollback marker was removed, upgrade is succeeded"21 echo "rollback marker was removed, upgrade is succeeded"22 fi22 fi23 '';23 '';24 path = [24 path = [25 # Should have nix-command support25 # Should have nix-command support26 config.nix.package26 config.nix.package27 ];27 ];28 serviceConfig.Type = "exec";28 serviceConfig.Type = "exec";29 unitConfig = {29 unitConfig = {30 X-StopOnRemoval = false;30 X-StopOnRemoval = false;31 X-RestartIfChanged = false;32 X-StopIfChanged = false;31 };33 };32 };34 };333534 systemd.timers.rollback-watchdog = {36 systemd.timers.rollback-watchdog = {35 description = "Timer for rollback watchdog";37 description = "Timer for rollback watchdog";36 wantedBy = ["timers.target"];38 wantedBy = ["timers.target"];37 timerConfig = {39 timerConfig = {38 OnUnitActiveSec = "3min";40 OnActiveSec = "3min";39 RemainAfterElapse = false;41 RemainAfterElapse = false;40 };42 };41 unitConfig = {43 unitConfig = {