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 in
{ {
options.statelessUptimeKuma = { options.statelessUptimeKuma = {
build.json = lib.mkOption { build = {
internal = true; json = lib.mkOption { type = lib.types.package; };
visible = false; script = lib.mkOption { type = lib.types.package; };
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 = { probesConfig = {
monitors = lib.mkOption { monitors = lib.mkOption {
@ -31,6 +38,15 @@ in
}; };
}; };
config.statelessUptimeKuma = { 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 in
((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build.json ((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build