diff --git a/nixos/module.nix b/nixos/module.nix index e7f1dd0..7c4e43b 100644 --- a/nixos/module.nix +++ b/nixos/module.nix @@ -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} + ''; + }; + }; }; } diff --git a/tests/testmodule.nix b/tests/testmodule.nix index cc9ae5f..5995ccc 100644 --- a/tests/testmodule.nix +++ b/tests/testmodule.nix @@ -11,4 +11,4 @@ let }; }; in -((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build.json +((import ../. { }).evalModules { modules = [ module ]; }).config.statelessUptimeKuma.build