mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-19 08:31:01 +03:00

After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.
Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.
A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.
This commit was automatically created and can be verified using
nix-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
--argstr baseRev 0128fbb0a5
result/bin/apply-formatting $NIXPKGS_PATH
118 lines
3.4 KiB
Nix
118 lines
3.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
options,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.prometheus.exporters.postfix;
|
|
inherit (lib)
|
|
mkOption
|
|
types
|
|
mkIf
|
|
escapeShellArg
|
|
concatStringsSep
|
|
optional
|
|
;
|
|
in
|
|
{
|
|
port = 9154;
|
|
extraOpts = {
|
|
group = mkOption {
|
|
type = types.str;
|
|
description = ''
|
|
Group under which the postfix exporter shall be run.
|
|
It should match the group that is allowed to access the
|
|
`showq` socket in the `queue/public/` directory.
|
|
Defaults to `services.postfix.setgidGroup` when postfix is enabled.
|
|
'';
|
|
};
|
|
telemetryPath = mkOption {
|
|
type = types.str;
|
|
default = "/metrics";
|
|
description = ''
|
|
Path under which to expose metrics.
|
|
'';
|
|
};
|
|
logfilePath = mkOption {
|
|
type = types.path;
|
|
default = "/var/log/postfix_exporter_input.log";
|
|
example = "/var/log/mail.log";
|
|
description = ''
|
|
Path where Postfix writes log entries.
|
|
This file will be truncated by this exporter!
|
|
'';
|
|
};
|
|
showqPath = mkOption {
|
|
type = types.path;
|
|
default = "/var/lib/postfix/queue/public/showq";
|
|
example = "/var/spool/postfix/public/showq";
|
|
description = ''
|
|
Path where Postfix places its showq socket.
|
|
'';
|
|
};
|
|
systemd = {
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = ''
|
|
Whether to enable reading metrics from the systemd journal instead of from a logfile
|
|
'';
|
|
};
|
|
unit = mkOption {
|
|
type = types.str;
|
|
default = "postfix.service";
|
|
description = ''
|
|
Name of the postfix systemd unit.
|
|
'';
|
|
};
|
|
slice = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = ''
|
|
Name of the postfix systemd slice.
|
|
This overrides the {option}`systemd.unit`.
|
|
'';
|
|
};
|
|
journalPath = mkOption {
|
|
type = types.nullOr types.path;
|
|
default = null;
|
|
description = ''
|
|
Path to the systemd journal.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
serviceOpts = {
|
|
after = mkIf cfg.systemd.enable [ cfg.systemd.unit ];
|
|
serviceConfig = {
|
|
DynamicUser = false;
|
|
# By default, each prometheus exporter only gets AF_INET & AF_INET6,
|
|
# but AF_UNIX is needed to read from the `showq`-socket.
|
|
RestrictAddressFamilies = [ "AF_UNIX" ];
|
|
SupplementaryGroups = mkIf cfg.systemd.enable [ "systemd-journal" ];
|
|
ExecStart = ''
|
|
${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \
|
|
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
|
--web.telemetry-path ${cfg.telemetryPath} \
|
|
--postfix.showq_path ${escapeShellArg cfg.showqPath} \
|
|
${concatStringsSep " \\\n " (
|
|
cfg.extraFlags
|
|
++ optional cfg.systemd.enable "--systemd.enable"
|
|
++ optional cfg.systemd.enable (
|
|
if cfg.systemd.slice != null then
|
|
"--systemd.slice ${cfg.systemd.slice}"
|
|
else
|
|
"--systemd.unit ${cfg.systemd.unit}"
|
|
)
|
|
++ optional (
|
|
cfg.systemd.enable && (cfg.systemd.journalPath != null)
|
|
) "--systemd.journal_path ${escapeShellArg cfg.systemd.journalPath}"
|
|
++ optional (!cfg.systemd.enable) "--postfix.logfile_path ${escapeShellArg cfg.logfilePath}"
|
|
)}
|
|
'';
|
|
};
|
|
};
|
|
}
|