about summary refs log tree commit diff
path: root/modules/uptime-kuma.nix
diff options
context:
space:
mode:
authorazahi <azat@bahawi.net>2024-10-29 01:00:11 +0300
committerazahi <azat@bahawi.net>2024-10-29 01:00:11 +0300
commita41cd27691891e26b575c26455734851b5216488 (patch)
treec4650e568ede2a0f327e787ea921c306d3111d6b /modules/uptime-kuma.nix
parent2024-10-28 (diff)
2024-10-29 HEAD master
Diffstat (limited to 'modules/uptime-kuma.nix')
-rw-r--r--modules/uptime-kuma.nix49
1 files changed, 49 insertions, 0 deletions
diff --git a/modules/uptime-kuma.nix b/modules/uptime-kuma.nix
new file mode 100644
index 0000000..5f48d0d
--- /dev/null
+++ b/modules/uptime-kuma.nix
@@ -0,0 +1,49 @@
+{
+  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;
+      };
+    };
+  };
+}

Consider giving Nix/NixOS a try! <3