1 { config, lib, pkgs, ... }:
3 cfg = config.services.prometheus.alertmanagerIrcRelay;
5 configFormat = pkgs.formats.yaml { };
6 configFile = configFormat.generate "alertmanager-irc-relay.yml" cfg.settings;
9 options.services.prometheus.alertmanagerIrcRelay = {
10 enable = lib.mkEnableOption "Alertmanager IRC Relay";
12 package = lib.mkPackageOption pkgs "alertmanager-irc-relay" { };
14 extraFlags = lib.mkOption {
15 type = lib.types.listOf lib.types.str;
17 description = "Extra command line options to pass to alertmanager-irc-relay.";
20 settings = lib.mkOption {
21 type = configFormat.type;
22 example = lib.literalExpression ''
24 http_host = "localhost";
27 irc_host = "irc.example.com";
29 irc_nickname = "myalertbot";
32 { name = "#mychannel"; }
37 Configuration for Alertmanager IRC Relay as a Nix attribute set.
38 For a reference, check out the
39 [example configuration](https://github.com/google/alertmanager-irc-relay#configuring-and-running-the-bot)
41 [source code](https://github.com/google/alertmanager-irc-relay/blob/master/config.go).
43 Note: The webhook's URL MUST point to the IRC channel where the message
44 should be posted. For `#mychannel` from the example, this would be
45 `http://localhost:8080/mychannel`.
50 config = lib.mkIf cfg.enable {
51 systemd.services.alertmanager-irc-relay = {
52 description = "Alertmanager IRC Relay";
54 wantedBy = [ "multi-user.target" ];
55 after = [ "network-online.target" ];
59 ${cfg.package}/bin/alertmanager-irc-relay \
60 -config ${configFile} \
61 ${lib.escapeShellArgs cfg.extraFlags}
65 NoNewPrivileges = true;
67 ProtectProc = "invisible";
68 ProtectSystem = "strict";
69 ProtectHome = "tmpfs";
72 PrivateDevices = true;
75 ProtectHostname = true;
77 ProtectKernelTunables = true;
78 ProtectKernelModules = true;
79 ProtectKernelLogs = true;
80 ProtectControlGroups = true;
82 RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ];
83 RestrictRealtime = true;
84 RestrictSUIDSGID = true;
98 meta.maintainers = [ lib.maintainers.oxzi ];