From 5306070bc5709d7198c89342380c98779b11b6e3 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sat, 14 Sep 2024 22:13:13 +0000 Subject: [PATCH] add uptime-kuma status page --- flake.nix | 1 + hosts/flame/default.nix | 1 + modules/nixos/services/default.nix | 1 + modules/nixos/services/ntfy.nix | 2 +- modules/nixos/services/uptime-kuma.nix | 39 ++++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 modules/nixos/services/uptime-kuma.nix diff --git a/flake.nix b/flake.nix index 554ebe4..96dc7d8 100644 --- a/flake.nix +++ b/flake.nix @@ -245,6 +245,7 @@ content = "cloud.${baseName}"; books = "books.${baseName}"; download = "download.${baseName}"; + status = "status.${baseName}"; transmission = "transmission.${baseName}"; }; }; diff --git a/hosts/flame/default.nix b/hosts/flame/default.nix index abf4537..0025236 100644 --- a/hosts/flame/default.nix +++ b/hosts/flame/default.nix @@ -82,6 +82,7 @@ inputs.nixpkgs.lib.nixosSystem rec { services.minecraft-server.enable = true; # Setup Minecraft server services.n8n.enable = true; services.ntfy-sh.enable = true; + services.uptime-kuma.enable = true; system.autoUpgrade.enable = true; # Allows private remote access over the internet diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index 7173ad8..c7fce94 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -35,6 +35,7 @@ ./secrets.nix ./sshd.nix ./transmission.nix + ./uptime-kuma.nix ./vaultwarden.nix ./victoriametrics.nix ./wireguard.nix diff --git a/modules/nixos/services/ntfy.nix b/modules/nixos/services/ntfy.nix index 8d2ddc9..3c6bd80 100644 --- a/modules/nixos/services/ntfy.nix +++ b/modules/nixos/services/ntfy.nix @@ -4,7 +4,7 @@ config = lib.mkIf config.services.ntfy-sh.enable { services.ntfy-sh = { - settings = rec { + settings = { base-url = "https://${config.hostnames.notifications}"; upstream-base-url = "https://ntfy.sh"; listen-http = ":8333"; diff --git a/modules/nixos/services/uptime-kuma.nix b/modules/nixos/services/uptime-kuma.nix new file mode 100644 index 0000000..7c64da5 --- /dev/null +++ b/modules/nixos/services/uptime-kuma.nix @@ -0,0 +1,39 @@ +{ config, lib, ... }: +{ + + options = { + hostnames.status = lib.mkOption { + type = lib.types.str; + description = "Hostname for status page (Uptime-Kuma)."; + }; + }; + + config = lib.mkIf config.services.uptime-kuma.enable { + + services.uptime-kuma = { + settings = { + PORT = "3033"; + }; + }; + + # Allow web traffic to Caddy + caddy.routes = [ + { + match = [ { host = [ config.hostnames.status ]; } ]; + handle = [ + { + handler = "reverse_proxy"; + upstreams = [ + { dial = "localhost:${config.services.uptime-kuma.settings.PORT}"; } + ]; + } + ]; + } + ]; + + # Configure Cloudflare DNS to point to this machine + services.cloudflare-dyndns.domains = [ config.hostnames.status ]; + + }; + +}