1 { config, pkgs, lib, ... }:
5 cfg = config.services.kthxbye;
9 options.services.kthxbye = {
10 enable = mkEnableOption (mdDoc "kthxbye alert acknowledgement management daemon");
14 default = pkgs.kthxbye;
15 defaultText = literalExpression "pkgs.kthxbye";
16 description = mdDoc ''
17 The kthxbye package that should be used.
21 openFirewall = mkOption {
24 description = mdDoc ''
25 Whether to open ports in the firewall needed for the daemon to function.
29 extraOptions = mkOption {
30 type = with types; listOf str;
32 description = mdDoc ''
33 Extra command line options.
35 Documentation can be found [here](https://github.com/prymitive/kthxbye/blob/main/README.md).
37 example = literalExpression ''
39 "-extend-with-prefix 'ACK!'"
48 description = mdDoc ''
49 Alertmanager request timeout duration in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
55 default = "http://localhost:9093";
56 description = mdDoc ''
57 Alertmanager URI to use.
59 example = "https://alertmanager.example.com";
66 description = mdDoc ''
67 Extend silences by adding DURATION seconds.
69 DURATION should be provided in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
74 extendIfExpiringIn = mkOption {
77 description = mdDoc ''
78 Extend silences that are about to expire in the next DURATION seconds.
80 DURATION should be provided in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
85 extendWithPrefix = mkOption {
88 description = mdDoc ''
89 Extend silences with comment starting with PREFIX string.
91 example = "!perma-silence";
97 description = mdDoc ''
98 Silence check interval duration in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
103 listenAddress = mkOption {
106 description = mdDoc ''
107 The address to listen on for HTTP requests.
109 example = "127.0.0.1";
115 description = mdDoc ''
116 The port to listen on for HTTP requests.
123 description = mdDoc ''
124 Format logged messages as JSON.
128 maxDuration = mkOption {
129 type = with types; nullOr str;
131 description = mdDoc ''
132 Maximum duration of a silence, it won't be extended anymore after reaching it.
134 Duration should be provided in the [time.Duration](https://pkg.go.dev/time#ParseDuration) format.
140 config = mkIf cfg.enable {
141 systemd.services.kthxbye = {
142 description = "kthxbye Alertmanager ack management daemon";
143 wantedBy = [ "multi-user.target" ];
145 ${cfg.package}/bin/kthxbye \
146 -alertmanager.timeout ${cfg.alertmanager.timeout} \
147 -alertmanager.uri ${cfg.alertmanager.uri} \
148 -extend-by ${cfg.extendBy} \
149 -extend-if-expiring-in ${cfg.extendIfExpiringIn} \
150 -extend-with-prefix ${cfg.extendWithPrefix} \
151 -interval ${cfg.interval} \
152 -listen ${cfg.listenAddress}:${toString cfg.port} \
153 ${optionalString cfg.logJSON "-log-json"} \
154 ${optionalString (cfg.maxDuration != null) "-max-duration ${cfg.maxDuration}"} \
155 ${concatStringsSep " " cfg.extraOptions}
160 Restart = "on-failure";
164 networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];