stateless-uptime-kuma/nixos/module.nix

55 lines
1.3 KiB
Nix
Raw Normal View History

2024-04-18 18:23:11 +02:00
{
config,
lib,
pkgs,
...
}:
2024-04-18 18:19:59 +02:00
let
2024-04-18 18:23:11 +02:00
probesFormat = pkgs.formats.json { };
2024-04-18 18:19:59 +02:00
cfg = config.statelessUptimeKuma;
in
{
options.statelessUptimeKuma = {
2024-04-18 19:36:28 +02:00
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`.
'';
2024-04-18 18:19:59 +02:00
};
2024-04-18 20:27:17 +02:00
lib = lib.mkOption { type = lib.types.raw; };
2024-04-18 18:19:59 +02:00
probesConfig = {
monitors = lib.mkOption {
inherit (probesFormat) type;
2024-04-18 18:23:11 +02:00
default = [ ];
2024-04-18 18:19:59 +02:00
};
tags = lib.mkOption {
inherit (probesFormat) type;
2024-04-18 18:23:11 +02:00
default = [ ];
2024-04-18 18:19:59 +02:00
};
notifications = lib.mkOption {
inherit (probesFormat) type;
2024-04-18 18:23:11 +02:00
default = [ ];
2024-04-18 18:19:59 +02:00
};
};
};
config.statelessUptimeKuma = {
2024-04-18 20:27:17 +02:00
lib = import ../lib { inherit lib; };
2024-04-18 19:36:28 +02:00
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}
'';
};
};
2024-04-18 18:19:59 +02:00
};
}