nixos-config/common/services/autoupgrade.nix

42 lines
1.1 KiB
Nix
Raw Normal View History

2024-05-24 12:57:53 +02:00
{pkgs, ...}: {
2024-06-07 18:06:59 +02:00
systemd.timers."nix-auto-upgrade" = {
wantedBy = ["timers.target"];
timerConfig = {
FixedRandomDelay = false;
RandomizedDelaySec = 0;
OnCalendar = "weekly";
Persistent = true;
Unit = "nix-auto-upgrade";
};
};
2024-05-24 13:43:30 +02:00
2024-06-07 18:06:59 +02:00
systemd.services."nix-auto-upgrade" = {
unitConfig = {
After="network-online.target";
Description="NixOS Upgrade";
Wants="network-online.target";
# X-StopOnRemoval=false; ?
};
serviceConfig = {
Type = "oneshot";
User = "root";
WorkingDirectory = /etc/nixos/nixos-config;
2024-05-24 12:51:50 +02:00
2024-06-07 18:06:59 +02:00
# X-RestartIfChanged=false; ?
};
2024-05-24 12:51:50 +02:00
2024-06-07 18:06:59 +02:00
script = ''
set -eu
2024-05-24 12:51:50 +02:00
2024-06-07 18:06:59 +02:00
${pkgs.nixos-rebuild}/bin/nixos-rebuild switch -L --flake git+https://gitea.com/tasiaiso/nixos-config --upgrade
${pkgs.curl}/bin/curl \
-H "Title: NixOS upgrade done" \
-H "Priority: low" \
-H "Tags: low" \
-d "$(cat /etc/hostname): upgrade script done" \
ntfy.sh/tasiaiso_upgrades &> /dev/null # Please don't make me learn how to manage secrets
'';
2024-05-24 12:51:50 +02:00
};
2024-05-24 12:57:53 +02:00
}