forked from mirrors/nixpkgs
Merge pull request #29890 from mbrgm/nullmailer-fix
nixos/nullmailer: fixes and `remotesFile` option
This commit is contained in:
commit
12ac88af1d
|
@ -35,6 +35,18 @@ with lib;
|
|||
description = "Whether to set the system sendmail to nullmailer's.";
|
||||
};
|
||||
|
||||
remotesFile = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Path to the <code>remotes</code> control file. This file contains a
|
||||
list of remote servers to which to send each message.
|
||||
|
||||
See <code>man 8 nullmailer-send</code> for syntax and available
|
||||
options.
|
||||
'';
|
||||
};
|
||||
|
||||
config = {
|
||||
adminaddr = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
|
@ -142,7 +154,16 @@ with lib;
|
|||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
If set, content will override the envelope sender on all messages.
|
||||
A list of remote servers to which to send each message. Each line
|
||||
contains a remote host name or address followed by an optional
|
||||
protocol string, separated by white space.
|
||||
|
||||
See <code>man 8 nullmailer-send</code> for syntax and available
|
||||
options.
|
||||
|
||||
WARNING: This is stored world-readable in the nix store. If you need
|
||||
to specify any secret credentials here, consider using the
|
||||
<code>remotesFile</code> option instead.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -164,13 +185,19 @@ with lib;
|
|||
cfg = config.services.nullmailer;
|
||||
in mkIf cfg.enable {
|
||||
|
||||
assertions = [
|
||||
{ assertion = cfg.config.remotes == null || cfg.remotesFile == null;
|
||||
message = "Only one of `remotesFile` or `config.remotes` may be used at a time.";
|
||||
}
|
||||
];
|
||||
|
||||
environment = {
|
||||
systemPackages = [ pkgs.nullmailer ];
|
||||
etc = let
|
||||
getval = attr: builtins.getAttr attr cfg.config;
|
||||
attrs = builtins.attrNames cfg.config;
|
||||
attrs' = builtins.filter (attr: ! isNull (getval attr)) attrs;
|
||||
in foldl' (as: attr: as // { "nullmailer/${attr}".text = getval attr; }) {} attrs';
|
||||
validAttrs = filterAttrs (name: value: value != null) cfg.config;
|
||||
in
|
||||
(foldl' (as: name: as // { "nullmailer/${name}".text = validAttrs.${name}; }) {} (attrNames validAttrs))
|
||||
// optionalAttrs (cfg.remotesFile != null) { "nullmailer/remotes".source = cfg.remotesFile; };
|
||||
};
|
||||
|
||||
users = {
|
||||
|
@ -192,7 +219,7 @@ with lib;
|
|||
|
||||
preStart = ''
|
||||
mkdir -p /var/spool/nullmailer/{queue,tmp}
|
||||
rm -f var/spool/nullmailer/trigger && mkfifo -m 660 /var/spool/nullmailer/trigger
|
||||
rm -f /var/spool/nullmailer/trigger && mkfifo -m 660 /var/spool/nullmailer/trigger
|
||||
chown ${cfg.user} /var/spool/nullmailer/*
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue