feat: add script to module

This commit is contained in:
sinavir 2024-04-18 19:36:28 +02:00
parent 9b4e87af6f
commit c4dfae1833
2 changed files with 22 additions and 6 deletions

View file

@ -10,10 +10,17 @@ let
in
{
options.statelessUptimeKuma = {
build.json = lib.mkOption {
internal = true;
visible = false;
type = lib.types.package;
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 {
@ -31,6 +38,15 @@ in
};
};
config.statelessUptimeKuma = {
build.json = probesFormat.generate "probes.json" cfg.probesConfig;
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}
'';
};
};
};
}

View file

@ -11,4 +11,4 @@ let
};
};
in
((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build.json
((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build