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.";
|
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 = {
|
config = {
|
||||||
adminaddr = mkOption {
|
adminaddr = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
@ -142,7 +154,16 @@ with lib;
|
|||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
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;
|
cfg = config.services.nullmailer;
|
||||||
in mkIf cfg.enable {
|
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 = {
|
environment = {
|
||||||
systemPackages = [ pkgs.nullmailer ];
|
systemPackages = [ pkgs.nullmailer ];
|
||||||
etc = let
|
etc = let
|
||||||
getval = attr: builtins.getAttr attr cfg.config;
|
validAttrs = filterAttrs (name: value: value != null) cfg.config;
|
||||||
attrs = builtins.attrNames cfg.config;
|
in
|
||||||
attrs' = builtins.filter (attr: ! isNull (getval attr)) attrs;
|
(foldl' (as: name: as // { "nullmailer/${name}".text = validAttrs.${name}; }) {} (attrNames validAttrs))
|
||||||
in foldl' (as: attr: as // { "nullmailer/${attr}".text = getval attr; }) {} attrs';
|
// optionalAttrs (cfg.remotesFile != null) { "nullmailer/remotes".source = cfg.remotesFile; };
|
||||||
};
|
};
|
||||||
|
|
||||||
users = {
|
users = {
|
||||||
@ -192,7 +219,7 @@ with lib;
|
|||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -p /var/spool/nullmailer/{queue,tmp}
|
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/*
|
chown ${cfg.user} /var/spool/nullmailer/*
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user