diff options
author | Jörg Thalheim <Mic92@users.noreply.github.com> | 2017-09-28 21:29:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-28 21:29:37 +0100 |
commit | 12ac88af1d5eaea7ad08d9fdd3d293158b692b12 (patch) | |
tree | 5f530cdcc93ca6ab2a1f14eda2c58e6ed76888f6 /nixos | |
parent | d4bdf302a3c6b9c7e00b14e3ae21597fad6d17d8 (diff) | |
parent | 91eb6cf82cc7fa2eaa2802f64a15ab75be726fae (diff) | |
download | nixlib-12ac88af1d5eaea7ad08d9fdd3d293158b692b12.tar nixlib-12ac88af1d5eaea7ad08d9fdd3d293158b692b12.tar.gz nixlib-12ac88af1d5eaea7ad08d9fdd3d293158b692b12.tar.bz2 nixlib-12ac88af1d5eaea7ad08d9fdd3d293158b692b12.tar.lz nixlib-12ac88af1d5eaea7ad08d9fdd3d293158b692b12.tar.xz nixlib-12ac88af1d5eaea7ad08d9fdd3d293158b692b12.tar.zst nixlib-12ac88af1d5eaea7ad08d9fdd3d293158b692b12.zip |
Merge pull request #29890 from mbrgm/nullmailer-fix
nixos/nullmailer: fixes and `remotesFile` option
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/mail/nullmailer.nix | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/nixos/modules/services/mail/nullmailer.nix b/nixos/modules/services/mail/nullmailer.nix index b2c738ab6ebd..59cb512c115b 100644 --- a/nixos/modules/services/mail/nullmailer.nix +++ b/nixos/modules/services/mail/nullmailer.nix @@ -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/* ''; |