libsearpc: 3.3-20230626 -> 3.3-20241031 fix build with GCC14 (#368185)
[NixPkgs.git] / nixos / modules / services / monitoring / prometheus / alertmanager-irc-relay.nix
blob4995663ed7cac1e6632a09a35733ef672d61a3d8
1 { config, lib, pkgs, ... }:
2 let
3   cfg = config.services.prometheus.alertmanagerIrcRelay;
5   configFormat = pkgs.formats.yaml { };
6   configFile = configFormat.generate "alertmanager-irc-relay.yml" cfg.settings;
7 in
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;
16       default = [];
17       description = "Extra command line options to pass to alertmanager-irc-relay.";
18     };
20     settings = lib.mkOption {
21       type = configFormat.type;
22       example = lib.literalExpression ''
23         {
24           http_host = "localhost";
25           http_port = 8000;
27           irc_host = "irc.example.com";
28           irc_port = 7000;
29           irc_nickname = "myalertbot";
31           irc_channels = [
32             { name = "#mychannel"; }
33           ];
34         }
35       '';
36       description = ''
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)
40         and the
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`.
46       '';
47     };
48   };
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" ];
57       serviceConfig = {
58         ExecStart = ''
59           ${cfg.package}/bin/alertmanager-irc-relay \
60           -config ${configFile} \
61           ${lib.escapeShellArgs cfg.extraFlags}
62         '';
64         DynamicUser = true;
65         NoNewPrivileges = true;
67         ProtectProc = "invisible";
68         ProtectSystem = "strict";
69         ProtectHome = "tmpfs";
71         PrivateTmp = true;
72         PrivateDevices = true;
73         PrivateIPC = true;
75         ProtectHostname = true;
76         ProtectClock = 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;
86         SystemCallFilter = [
87           "@system-service"
88           "~@cpu-emulation"
89           "~@privileged"
90           "~@reboot"
91           "~@setuid"
92           "~@swap"
93         ];
94       };
95     };
96   };
98   meta.maintainers = [ lib.maintainers.oxzi ];