ntfy
This commit is contained in:
@@ -10,6 +10,17 @@ let
|
||||
name = "attic";
|
||||
cfg = config.${namespace}.services.${name};
|
||||
|
||||
ntfyFailScript = pkgs.writeShellScript "nix-rebuild-cache-notify-failure" ''
|
||||
HOST="$(${pkgs.hostname}/bin/hostname)"
|
||||
${pkgs.curl}/bin/curl -sf \
|
||||
--user "$NTFY_USER:$NTFY_PASSWORD" \
|
||||
-H "Title: Nix cache rebuild FAILED on $HOST" \
|
||||
-H "Priority: high" \
|
||||
-H "Tags: rotating_light,nix_snowflake" \
|
||||
-d "The weekly nix-rebuild-cache job failed. Check: journalctl -u nix-rebuild-cache.service" \
|
||||
"https://ntfy.mjallen.dev/builds" || true
|
||||
'';
|
||||
|
||||
atticConfig = lib.${namespace}.mkModule {
|
||||
inherit config name;
|
||||
description = "attic Service";
|
||||
@@ -60,7 +71,9 @@ let
|
||||
StandardError = "journal+console";
|
||||
Restart = "no";
|
||||
TimeoutStartSec = "2h";
|
||||
EnvironmentFile = [ config.sops.templates."ntfy.env".path ];
|
||||
};
|
||||
unitConfig.OnFailure = "nix-rebuild-cache-notify-failure.service";
|
||||
path = with pkgs; [
|
||||
nix
|
||||
git
|
||||
@@ -112,6 +125,15 @@ let
|
||||
fi;
|
||||
'';
|
||||
};
|
||||
|
||||
nix-rebuild-cache-notify-failure = {
|
||||
description = "Notify ntfy on nix-rebuild-cache failure";
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${ntfyFailScript}";
|
||||
EnvironmentFile = [ config.sops.templates."ntfy.env".path ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Include timers for cache rebuilds
|
||||
|
||||
Reference in New Issue
Block a user