diff --git a/nixos/modules/services/monitoring/kthxbye.nix b/nixos/modules/services/monitoring/kthxbye.nix index 81f47fba6679..a4ea97f0fa75 100644 --- a/nixos/modules/services/monitoring/kthxbye.nix +++ b/nixos/modules/services/monitoring/kthxbye.nix @@ -1,33 +1,31 @@ { config, pkgs, lib, ... }: -with lib; - let cfg = config.services.kthxbye; in { options.services.kthxbye = { - enable = mkEnableOption "kthxbye alert acknowledgement management daemon"; + enable = lib.mkEnableOption "kthxbye alert acknowledgement management daemon"; - package = mkPackageOption pkgs "kthxbye" { }; + package = lib.mkPackageOption pkgs "kthxbye" { }; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to open ports in the firewall needed for the daemon to function. ''; }; - extraOptions = mkOption { - type = with types; listOf str; + extraOptions = lib.mkOption { + type = with lib.types; listOf str; default = []; description = '' Extra command line options. Documentation can be found [here](https://github.com/prymitive/kthxbye/blob/main/README.md). ''; - example = literalExpression '' + example = lib.literalExpression '' [ "-extend-with-prefix 'ACK!'" ]; @@ -35,16 +33,16 @@ in }; alertmanager = { - timeout = mkOption { - type = types.str; + timeout = lib.mkOption { + type = lib.types.str; default = "1m0s"; description = '' Alertmanager request timeout duration in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format. ''; example = "30s"; }; - uri = mkOption { - type = types.str; + uri = lib.mkOption { + type = lib.types.str; default = "http://localhost:9093"; description = '' Alertmanager URI to use. @@ -53,8 +51,8 @@ in }; }; - extendBy = mkOption { - type = types.str; + extendBy = lib.mkOption { + type = lib.types.str; default = "15m0s"; description = '' Extend silences by adding DURATION seconds. @@ -64,8 +62,8 @@ in example = "6h0m0s"; }; - extendIfExpiringIn = mkOption { - type = types.str; + extendIfExpiringIn = lib.mkOption { + type = lib.types.str; default = "5m0s"; description = '' Extend silences that are about to expire in the next DURATION seconds. @@ -75,8 +73,8 @@ in example = "1m0s"; }; - extendWithPrefix = mkOption { - type = types.str; + extendWithPrefix = lib.mkOption { + type = lib.types.str; default = "ACK!"; description = '' Extend silences with comment starting with PREFIX string. @@ -84,8 +82,8 @@ in example = "!perma-silence"; }; - interval = mkOption { - type = types.str; + interval = lib.mkOption { + type = lib.types.str; default = "45s"; description = '' Silence check interval duration in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format. @@ -93,8 +91,8 @@ in example = "30s"; }; - listenAddress = mkOption { - type = types.str; + listenAddress = lib.mkOption { + type = lib.types.str; default = "0.0.0.0"; description = '' The address to listen on for HTTP requests. @@ -102,24 +100,24 @@ in example = "127.0.0.1"; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 8080; description = '' The port to listen on for HTTP requests. ''; }; - logJSON = mkOption { - type = types.bool; + logJSON = lib.mkOption { + type = lib.types.bool; default = false; description = '' Format logged messages as JSON. ''; }; - maxDuration = mkOption { - type = with types; nullOr str; + maxDuration = lib.mkOption { + type = with lib.types; nullOr str; default = null; description = '' Maximum duration of a silence, it won't be extended anymore after reaching it. @@ -130,7 +128,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.kthxbye = { description = "kthxbye Alertmanager ack management daemon"; wantedBy = [ "multi-user.target" ]; @@ -143,9 +141,9 @@ in -extend-with-prefix ${cfg.extendWithPrefix} \ -interval ${cfg.interval} \ -listen ${cfg.listenAddress}:${toString cfg.port} \ - ${optionalString cfg.logJSON "-log-json"} \ - ${optionalString (cfg.maxDuration != null) "-max-duration ${cfg.maxDuration}"} \ - ${concatStringsSep " " cfg.extraOptions} + ${lib.optionalString cfg.logJSON "-log-json"} \ + ${lib.optionalString (cfg.maxDuration != null) "-max-duration ${cfg.maxDuration}"} \ + ${lib.concatStringsSep " " cfg.extraOptions} ''; serviceConfig = { Type = "simple"; @@ -154,6 +152,6 @@ in }; }; - networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ]; + networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.port ]; }; }