feat: add initial setup for declarative uptime-kuma monitors

This commit is contained in:
Julien Malka 2024-12-08 13:23:45 +01:00
parent f3001378ad
commit 4bad661036
Signed by: Luj
GPG key ID: 6FC74C847011FD83
4 changed files with 41 additions and 21 deletions

View file

@ -50,9 +50,6 @@ import "${nixpkgs}/nixos/lib/eval-config.nix" {
}); });
# Packages comming from other repositories # Packages comming from other repositories
lila-build-hook = (import inputs.lila).packages.${system}.utils; lila-build-hook = (import inputs.lila).packages.${system}.utils;
statelessUptimeKuma =
pkgs.callPackage "${inputs.stateless-uptime-kuma}/stateless-uptime-kuma.nix"
{ };
# My own packages # My own packages
keycloak-keywind = prev.pkgs.callPackage ../packages/keycloak-keywind { }; keycloak-keywind = prev.pkgs.callPackage ../packages/keycloak-keywind { };
hydrasect = prev.pkgs.callPackage ../packages/hydrasect { }; hydrasect = prev.pkgs.callPackage ../packages/hydrasect { };

View file

@ -165,9 +165,9 @@
"type": "Git", "type": "Git",
"fetchType": "git", "fetchType": "git",
"branch": "truly-deterministic", "branch": "truly-deterministic",
"revision": "880f444ff7862d6127b051cf1a993ad1585b1652", "revision": "caf3169829647809805caaf968c8c0d4015ef187",
"url": "https://git.dgnum.eu/Luj/stateless-uptime-kuma.git", "url": "https://git.dgnum.eu/Luj/stateless-uptime-kuma.git",
"hash": "sha256-l9fgwesnmFxasCaYUCD7L9bGGJXytLuwtx3CZMgpwJg=", "hash": "sha256-tux43mzd1rrlpTEhcQ9PiJBse9+SGEcWY/9F8cxX+Po=",
"submodules": false "submodules": false
}, },
"unstable": { "unstable": {

View file

@ -1,6 +1,7 @@
{ {
pkgs, pkgs,
config, config,
inputs,
... ...
}: }:
{ {
@ -23,24 +24,12 @@
}; };
age.secrets."stateless-uptime-kuma-password".file = ../../secrets/stateless-uptime-kuma-password.age; age.secrets."stateless-uptime-kuma-password".file = ../../secrets/stateless-uptime-kuma-password.age;
nixpkgs.overlays = [
(import "${inputs.stateless-uptime-kuma}/overlay.nix")
];
statelessUptimeKuma = { statelessUptimeKuma = {
enableService = true; enableService = true;
probesConfig = {
monitors = {
"mdr" = {
url = "https://82.67.34.230";
keyword = "Ulm";
type = "keyword";
accepted_statuscodes = [ "200-299" ];
headers = ''
{
"Host": "julienmalka.me"
}
'';
};
};
};
extraFlags = [ extraFlags = [
"-s" "-s"
"-v DEBUG" "-v DEBUG"

View file

@ -59,6 +59,39 @@ in
''; '';
systemConfig = _: { systemConfig = _: {
statelessUptimeKuma.probesConfig.monitors = lib.mkIf (name != "default") {
"${name} - IPv4" = {
url = "https://${
if (hasSuffix "luj" name) then
config.machine.meta.ips.vpn.ipv4
else
config.machine.meta.ips.public.ipv4
}";
type = "http";
accepted_statuscodes = [ "200-299" ];
headers = ''
{
"Host": "${name}"
}
'';
};
"${name} - IPv6" = {
url = "https://[${
if (hasSuffix "luj" name) then
config.machine.meta.ips.vpn.ipv6
else
config.machine.meta.ips.public.ipv6
}]";
type = "http";
accepted_statuscodes = [ "200-299" ];
headers = ''
{
"Host": "${name}"
}
'';
};
};
security.acme.certs = lib.optionalAttrs (hasSuffix "luj" name) { security.acme.certs = lib.optionalAttrs (hasSuffix "luj" name) {
"${name}".server = lib.mkIf (hasSuffix "luj" name) "https://ca.luj/acme/acme/directory"; "${name}".server = lib.mkIf (hasSuffix "luj" name) "https://ca.luj/acme/acme/directory";
}; };
@ -134,6 +167,7 @@ in
]; ];
machine = mergeSub (c: c.machine); machine = mergeSub (c: c.machine);
statelessUptimeKuma = mergeSub (c: c.statelessUptimeKuma);
}; };
} }