stateless-uptime-kuma/nixos/module.nix
2024-04-18 19:36:28 +02:00

52 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
probesFormat = pkgs.formats.json { };
cfg = config.statelessUptimeKuma;
in
{
options.statelessUptimeKuma = {
build = {
json = lib.mkOption { type = lib.types.package; };
script = lib.mkOption { type = lib.types.package; };
};
extraFlags = lib.mkOption {
default = [ ];
example = [ "--scrape-http-keywords" ];
type = with lib.types; listOf str;
description = lib.mdDoc ''
Extra arguments to use for executing `stateless-uptime-kuma`.
'';
};
probesConfig = {
monitors = lib.mkOption {
inherit (probesFormat) type;
default = [ ];
};
tags = lib.mkOption {
inherit (probesFormat) type;
default = [ ];
};
notifications = lib.mkOption {
inherit (probesFormat) type;
default = [ ];
};
};
};
config.statelessUptimeKuma = {
build = {
json = probesFormat.generate "probes.json" cfg.probesConfig;
script = pkgs.writeShellApplication {
name = "deploy-uptime-kuma-probes";
runtimeInputs = [ pkgs.statelessUptimeKuma ];
text = ''
stateless-uptime-kuma apply-json -f ${cfg.build.json} ${cfg.extraFlags}
'';
};
};
};
}