From 819c54d46f8d9431cdff92138af81cc2992b88b3 Mon Sep 17 00:00:00 2001 From: tux Date: Sat, 8 Aug 2026 15:34:44 +0530 Subject: [PATCH] feat: add uptime-kuma module --- modules/hosts/alpha/config.nix | 6 +++ modules/nixos/services/uptime-kuma.nix | 51 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 modules/nixos/services/uptime-kuma.nix diff --git a/modules/hosts/alpha/config.nix b/modules/hosts/alpha/config.nix index b20909f..b59a165 100644 --- a/modules/hosts/alpha/config.nix +++ b/modules/hosts/alpha/config.nix @@ -44,6 +44,12 @@ domain = "lab.tux.rs"; }; + uptime-kuma = { + enable = true; + port = 1111; + domain = "status.lab.tux.rs"; + }; + mediaflow-proxy = { enable = true; port = 8888; diff --git a/modules/nixos/services/uptime-kuma.nix b/modules/nixos/services/uptime-kuma.nix new file mode 100644 index 0000000..b3a88f4 --- /dev/null +++ b/modules/nixos/services/uptime-kuma.nix @@ -0,0 +1,51 @@ +{ + flake.modules.nixos.services = + { + config, + lib, + ... + }: + with lib; + let + cfg = config.tnix.services.uptime-kuma; + port = toString cfg.port; + acmeHost = config.tnix.services.nginx.domain; + in + { + options.tnix.services.uptime-kuma = { + enable = mkEnableOption "Uptime Kuma"; + + port = mkOption { + type = types.port; + default = 1111; + description = "Port on which Uptime Kuma listens"; + }; + + domain = mkOption { + type = types.str; + default = ""; + description = "Domain on which nginx serves Uptime Kuma (disabled when empty)"; + }; + }; + + config = mkIf cfg.enable { + services = { + uptime-kuma = { + enable = true; + settings = { + HOST = "127.0.0.1"; + PORT = port; + }; + }; + + nginx.virtualHosts.${cfg.domain} = mkIf (cfg.domain != "") { + forceSSL = acmeHost != ""; + useACMEHost = mkIf (acmeHost != "") acmeHost; + locations."/" = { + proxyPass = "http://127.0.0.1:${port}"; + }; + }; + }; + }; + }; +}