feat(monitoring): service status lookup

This commit is contained in:
arcnmx 2024-05-31 18:14:37 -07:00
parent f97ab24f47
commit ebfd1f5a9a
12 changed files with 273 additions and 103 deletions

49
nixos/access/gatus.nix Normal file
View file

@ -0,0 +1,49 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkDefault;
inherit (config.services) gatus;
name.shortServer = mkDefault "status";
upstreamName = "gatus'access";
in {
config.services.nginx = {
upstreams'.${upstreamName}.servers = {
local = {
enable = mkDefault gatus.enable;
addr = mkDefault "localhost";
port = mkIf gatus.enable (mkDefault gatus.settings.web.port);
};
service = {upstream, ...}: {
enable = mkIf upstream.servers.local.enable (mkDefault false);
accessService = {
name = "gatus";
};
};
};
virtualHosts = let
copyFromVhost = mkDefault "gatus";
locations = {
"/" = {
proxy.enable = true;
};
};
in {
gatus = {
inherit name locations;
proxy.upstream = mkDefault upstreamName;
};
gatus'local = {
inherit name locations;
ssl.cert = {
inherit copyFromVhost;
};
proxy = {
inherit copyFromVhost;
};
local.enable = mkDefault true;
};
};
};
}