mirror of
https://forgejo.altau.su/lego/lego-monitoring.git
synced 2026-03-10 04:41:10 +00:00
53 lines
1.4 KiB
Nix
53 lines
1.4 KiB
Nix
package:
|
|
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
{
|
|
options.services.lego-monitoring = {
|
|
enable = lib.mkEnableOption "lego-monitoring service.";
|
|
|
|
enabledCheckerSets = lib.mkOption {
|
|
type = lib.types.listOf (lib.types.enum [
|
|
"start"
|
|
"stop"
|
|
]);
|
|
default = [ ];
|
|
description = "List of enabled checker sets. Each checker set is a module which checks something and generates alerts based on check results.";
|
|
};
|
|
|
|
telegram = {
|
|
credsSecretPath = lib.mkOption {
|
|
type = lib.types.str;
|
|
description = "Path to a file containing Telegram api_id, api_hash, and bot token, separated by the `,` character.";
|
|
};
|
|
roomId = lib.mkOption {
|
|
type = lib.types.int;
|
|
description = "ID of chat where to send alerts.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = let
|
|
cfg = config.services.lego-monitoring;
|
|
json = pkgs.formats.json {};
|
|
serviceConfigFile = json.generate "config.json" {
|
|
enabled_checker_sets = cfg.enabledCheckerSets;
|
|
telegram = with cfg.telegram; {
|
|
creds_secret_path = credsSecretPath;
|
|
room_id = roomId;
|
|
};
|
|
};
|
|
in lib.mkIf cfg.enable {
|
|
systemd.services.lego-monitoring = {
|
|
name = "lego-monitoring.service";
|
|
description = "Lego-monitoring service";
|
|
script = "${package}/bin/lego-monitoring -c ${serviceConfigFile}";
|
|
wantedBy = [ "multi-user.target" ];
|
|
};
|
|
};
|
|
}
|