1{config, ...}: {2 3 4 5 67 systemd.services.rollback-watchdog = {8 description = "Rollback watchdog";9 script = ''10 set -eux11 if [ -f /etc/fleet_rollback_marker ]; then12 echo "found the rollback marker, switching to older generation"13 target=$(cat /etc/fleet_rollback_marker)14 echo "rolling back profile"15 nix profile rollback --profile /nix/var/nix/profiles/system --to "$target"16 echo "executing activation script"17 "/nix/var/nix/profiles/system-$target-link/bin/switch-to-configuration" switch || true18 echo "removing rollback marker"19 rm -f /etc/fleet_rollback_marker20 else21 echo "rollback marker was removed, upgrade is succeeded"22 fi23 '';24 path = [25 26 config.nix.package27 ];28 serviceConfig.Type = "exec";29 unitConfig = {30 X-StopOnRemoval = false;31 X-RestartIfChanged = false;32 X-StopIfChanged = false;33 };34 };3536 systemd.timers.rollback-watchdog = {37 description = "Timer for rollback watchdog";38 wantedBy = ["timers.target"];39 timerConfig = {40 OnActiveSec = "3min";41 RemainAfterElapse = false;42 };43 unitConfig = {44 ConditionPathExists = "/etc/fleet_rollback_marker";45 };46 };47}