1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{ secrets, pkgs, lib, config, ... }:
{
options.services.ntfysh-notify.enable = lib.mkEnableOption "";
config = lib.mkIf config.services.ntfysh-notify.enable {
age.secrets.ntfyshEnv.file = secrets.allNodes.ntfyshEnv;
systemd.services."ntfysh-notify-failure@" = {
serviceConfig = {
EnvironmentFile = config.age.secrets.ntfyshEnv.path;
ExecStart = ''
${pkgs.runtimeShell} -c '${lib.getExe pkgs.curl} -H "Tags: $NTFY_TAGS" -H "Firebase: no" -d "[%H] Service %i failed\n$(journalctl --unit %i --lines 5 --reverse --no-pager --boot | ${pkgs.coreutils}/bin/head -c 4095)" $NTFY_URL/$NTFY_TOPIC'
'';
};
};
};
}