all repos — nixfiles @ 691bf6e6bdbad175867c16d94a7ec8fcb5170c0a

System and user configuration, managed by nix and home-manager

r5: add uptime-monitor role

Alin
commit

691bf6e6bdbad175867c16d94a7ec8fcb5170c0a

parent

3db4409eacbb150efaf019c6beb38734fe031c3b

2 files changed, 44 insertions(+), 0 deletions(-)

changed files
M system/hosts/r5.nix → system/hosts/r5.nix
@@ -22,6 +22,7 @@ ../roles/exit-node.nix
../roles/syncthing.nix ../roles/home-automation.nix ../roles/tailscale-subnet-router.nix + ../roles/uptime-monitor.nix ../settings/services/searchix.nix ../settings/hardware/usb-serial-tty.nix ];
A system/roles/uptime-monitor.nix
@@ -0,0 +1,43 @@
+{ + config, + lib, + ... +}: +let + inherit (import ../../data) homenet pubnet; + inherit (config.networking) domain fqdn; + cfg = config.services.uptime-kuma.settings; + + extraConfig = '' + reverse_proxy localhost:${cfg.PORT} + ''; +in +{ + services.uptime-kuma = { + enable = true; + settings = { + HOST = "::"; + PORT = "3001"; + }; + }; + + services.caddy.virtualHosts = { + "status.${pubnet}" = { + inherit extraConfig; + }; + "status.${homenet}" = lib.mkIf (domain == homenet) { + extraConfig = '' + tls { + issuer internal { + ca home + } + } + '' + + extraConfig; + }; + }; + + services.dnsmasq.settings.cname = [ + "status.${domain},${fqdn}" + ]; +}