12{ config, ... }:3{4 5 6 7 89 systemd.services.rollback-watchdog = {10 description = "Rollback watchdog";11 script = ''12 set -eux13 if [ -f /etc/fleet_rollback_marker ]; then14 echo "found the rollback marker, switching to older generation"15 target=$(cat /etc/fleet_rollback_marker)16 echo "rolling back profile"17 nix profile rollback --profile /nix/var/nix/profiles/system --to "$target"18 echo "executing activation script"19 "/nix/var/nix/profiles/system-$target-link/bin/switch-to-configuration" switch || true20 echo "removing rollback marker"21 rm -f /etc/fleet_rollback_marker22 else23 echo "rollback marker was removed, upgrade is succeeded"24 fi25 '';26 path = [27 28 config.nix.package29 ];30 serviceConfig.Type = "exec";31 unitConfig = {32 X-StopOnRemoval = false;33 X-RestartIfChanged = false;34 X-StopIfChanged = false;35 };36 };3738 systemd.timers.rollback-watchdog = {39 description = "Timer for rollback watchdog";40 wantedBy = [ "timers.target" ];41 timerConfig = {42 OnActiveSec = "3min";43 RemainAfterElapse = false;44 };45 unitConfig = {46 ConditionPathExists = "/etc/fleet_rollback_marker";47 };48 };49}