diff --git a/backup.nix b/backup.nix index f584414..4764dfe 100644 --- a/backup.nix +++ b/backup.nix @@ -1,6 +1,27 @@ { pkgs, config, ... }: { - environment.systemPackages = [pkgs.restic]; + environment.systemPackages = with pkgs; [ + restic + libnotify + ]; + + systemd.services = { + notify-backup-b2-failed = { + description = "Notify on failed backup to B2"; + serviceConfig = { + Type = "oneshot"; + User = "nettika"; + }; + environment = { + DBUS_SESSION_BUS_ADDRESS = "unix:path=/run/user/1000/bus"; + }; + path = [ pkgs.libnotify ]; + script = "notify-send -u critical \"Backup to B2 failed\" \"$(journalctl -u restic-backups-b2 -n 5 -o cat)\""; + }; + restic-backups-b2 = { + onFailure = ["notify-backup-b2-failed.service"]; + }; + }; services.restic.backups = { b2 = {