12{config, ...}: {3 4 5 6 78 systemd.services.rollback-watchdog = {9 description = "Rollback watchdog";10 script = ''11 set -eux12 if [ -f /etc/fleet_rollback_marker ]; then13 echo "found the rollback marker, switching to older generation"14 target=$(cat /etc/fleet_rollback_marker)15 echo "rolling back profile"16 nix profile rollback --profile /nix/var/nix/profiles/system --to "$target"17 echo "executing activation script"18 "/nix/var/nix/profiles/system-$target-link/bin/switch-to-configuration" switch || true19 echo "removing rollback marker"20 rm -f /etc/fleet_rollback_marker21 else22 echo "rollback marker was removed, upgrade is succeeded"23 fi24 '';25 path = [26 27 config.nix.package28 ];29 serviceConfig.Type = "exec";30 unitConfig = {31 X-StopOnRemoval = false;32 X-RestartIfChanged = false;33 X-StopIfChanged = false;34 };35 };3637 systemd.timers.rollback-watchdog = {38 description = "Timer for rollback watchdog";39 wantedBy = ["timers.target"];40 timerConfig = {41 OnActiveSec = "3min";42 RemainAfterElapse = false;43 };44 unitConfig = {45 ConditionPathExists = "/etc/fleet_rollback_marker";46 };47 };48}