{ config, lib, libNginx, ... }: let cfg = config.nixfiles.modules.uptime-kuma; in { options.nixfiles.modules.uptime-kuma = { enable = lib.mkEnableOption "Uptime Kuma"; port = lib.mkOption { description = "Port."; type = lib.types.port; default = 9988; }; domain = lib.mkOption { description = "Domain name sans protocol scheme."; type = lib.types.str; default = "uptime.${config.networking.domain}"; }; }; config = lib.mkIf cfg.enable { ark.directories = [ "/var/lib/private/uptime-kuma" "/var/lib/uptime-kuma" ]; nixfiles.modules.nginx = { upstreams.uptime-kuma.servers."127.0.0.1:${toString cfg.port}" = { }; virtualHosts.${cfg.domain} = { locations."/".proxyPass = "http://uptime-kuma"; extraConfig = libNginx.config.internalOnly; }; }; services.uptime-kuma = { enable = true; settings = { UPTIME_KUMA_HOST = "127.0.0.1"; UPTIME_KUMA_PORT = toString cfg.port; }; }; }; }