{ 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"; }; }; }; }