nix/modules/monitoring/uptime-kuma.nix
2025-09-14 12:58:21 +02:00

74 lines
1.5 KiB
Nix

{
lib,
config,
pkgs,
...
}:
let
cfg = config.my.monitoring.uptime-kuma;
port = 3001;
in
{
options.my.monitoring.uptime-kuma = {
enable = lib.mkEnableOption "Enable Uptime Kuma module";
proxy = {
enable = lib.mkEnableOption "Set the proxy entry for this service";
domain = lib.mkOption {
default = "example.com";
type = lib.types.str;
description = ''
The domain where Caddy is reachable
'';
};
subdomain = lib.mkOption {
default = "up";
type = lib.types.str;
description = ''
The subdomain where Prometheus is reachable
'';
};
host = lib.mkOption {
default = "localhost";
type = lib.types.str;
description = ''
host name where the service is running
'';
};
};
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
services.uptime-kuma = {
enable = true;
settings = {
HOST = "0.0.0.0";
PORT = toString port;
};
};
systemd.services.uptime-kuma.serviceConfig = {
SupplementaryGroups = "docker";
};
networking.firewall.allowedTCPPorts = [ port ];
})
(lib.mkIf cfg.proxy.enable {
services.caddy = with cfg.proxy; {
virtualHosts."${subdomain}.${domain}".extraConfig = ''
reverse_proxy http://${host}:${toString port}
import cloudflare_${domain}
'';
};
})
];
}