add keepalive to system config for uptime kuma monitoring

This commit is contained in:
2026-04-27 14:16:14 -05:00
parent c64fbb845c
commit a0980ffd87
+46
View File
@@ -0,0 +1,46 @@
{
pkgs,
config,
lib,
...
}:
let
service = "keepalive";
cfg = config.system.${service};
in {
options.system.${service} = {
enable = lib.mkEnableOption "enables ${service}";
url = lib.mkOption {
type = lib.types.str;
default = "";
description = "url to ping for uptime-kuma keepalive";
};
interval = lib.mkOption {
type = lib.types.str;
default = "60s";
};
};
config = lib.mkIf cfg.enable {
systemd.services.keepalive = {
description = "send push for uptime kuma heartbeat";
serviceConfig = {
Type = "oneshot";
};
script = ''
${pkgs.curl}/bin/curl -fsSk \
"${cfg.url}" \
>/dev/null
'';
};
systemd.timers.keepalive = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "30s";
OnUnitActiveSec = cfg.interval;
Unit = "keepalive.service";
};
};
};
}