mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 11:45:45 +03:00

Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:
nix-build ci -A fmt.check
This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).
This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).
Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase
).
If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
107 lines
2.8 KiB
Nix
107 lines
2.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.prometheus.alertmanagerIrcRelay;
|
|
|
|
configFormat = pkgs.formats.yaml { };
|
|
configFile = configFormat.generate "alertmanager-irc-relay.yml" cfg.settings;
|
|
in
|
|
{
|
|
options.services.prometheus.alertmanagerIrcRelay = {
|
|
enable = lib.mkEnableOption "Alertmanager IRC Relay";
|
|
|
|
package = lib.mkPackageOption pkgs "alertmanager-irc-relay" { };
|
|
|
|
extraFlags = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ ];
|
|
description = "Extra command line options to pass to alertmanager-irc-relay.";
|
|
};
|
|
|
|
settings = lib.mkOption {
|
|
type = configFormat.type;
|
|
example = lib.literalExpression ''
|
|
{
|
|
http_host = "localhost";
|
|
http_port = 8000;
|
|
|
|
irc_host = "irc.example.com";
|
|
irc_port = 7000;
|
|
irc_nickname = "myalertbot";
|
|
|
|
irc_channels = [
|
|
{ name = "#mychannel"; }
|
|
];
|
|
}
|
|
'';
|
|
description = ''
|
|
Configuration for Alertmanager IRC Relay as a Nix attribute set.
|
|
For a reference, check out the
|
|
[example configuration](https://github.com/google/alertmanager-irc-relay#configuring-and-running-the-bot)
|
|
and the
|
|
[source code](https://github.com/google/alertmanager-irc-relay/blob/master/config.go).
|
|
|
|
Note: The webhook's URL MUST point to the IRC channel where the message
|
|
should be posted. For `#mychannel` from the example, this would be
|
|
`http://localhost:8080/mychannel`.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.services.alertmanager-irc-relay = {
|
|
description = "Alertmanager IRC Relay";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network-online.target" ];
|
|
|
|
serviceConfig = {
|
|
ExecStart = ''
|
|
${cfg.package}/bin/alertmanager-irc-relay \
|
|
-config ${configFile} \
|
|
${lib.escapeShellArgs cfg.extraFlags}
|
|
'';
|
|
|
|
DynamicUser = true;
|
|
NoNewPrivileges = true;
|
|
|
|
ProtectProc = "invisible";
|
|
ProtectSystem = "strict";
|
|
ProtectHome = "tmpfs";
|
|
|
|
PrivateTmp = true;
|
|
PrivateDevices = true;
|
|
PrivateIPC = true;
|
|
|
|
ProtectHostname = true;
|
|
ProtectClock = true;
|
|
ProtectKernelTunables = true;
|
|
ProtectKernelModules = true;
|
|
ProtectKernelLogs = true;
|
|
ProtectControlGroups = true;
|
|
|
|
RestrictAddressFamilies = [
|
|
"AF_INET"
|
|
"AF_INET6"
|
|
];
|
|
RestrictRealtime = true;
|
|
RestrictSUIDSGID = true;
|
|
|
|
SystemCallFilter = [
|
|
"@system-service"
|
|
"~@cpu-emulation"
|
|
"~@privileged"
|
|
"~@reboot"
|
|
"~@setuid"
|
|
"~@swap"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
meta.maintainers = [ lib.maintainers.oxzi ];
|
|
}
|