diff options
author | Joerg Thalheim <joerg@thalheim.io> | 2017-09-28 10:47:19 +0100 |
---|---|---|
committer | Joerg Thalheim <joerg@thalheim.io> | 2017-09-28 11:04:39 +0100 |
commit | 91eb6cf82cc7fa2eaa2802f64a15ab75be726fae (patch) | |
tree | 40cd9f01267eb3e1b95e8cf7a9c61765b351c5bc | |
parent | e741cc488190ab79e26b96d8e6f1402ab5965b6a (diff) | |
download | nixlib-91eb6cf82cc7fa2eaa2802f64a15ab75be726fae.tar nixlib-91eb6cf82cc7fa2eaa2802f64a15ab75be726fae.tar.gz nixlib-91eb6cf82cc7fa2eaa2802f64a15ab75be726fae.tar.bz2 nixlib-91eb6cf82cc7fa2eaa2802f64a15ab75be726fae.tar.lz nixlib-91eb6cf82cc7fa2eaa2802f64a15ab75be726fae.tar.xz nixlib-91eb6cf82cc7fa2eaa2802f64a15ab75be726fae.tar.zst nixlib-91eb6cf82cc7fa2eaa2802f64a15ab75be726fae.zip |
nullmailer: simplify config generation
-rw-r--r-- | nixos/modules/services/mail/nullmailer.nix | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/nixos/modules/services/mail/nullmailer.nix b/nixos/modules/services/mail/nullmailer.nix index c5af1d4d381b..59cb512c115b 100644 --- a/nixos/modules/services/mail/nullmailer.nix +++ b/nixos/modules/services/mail/nullmailer.nix @@ -194,18 +194,10 @@ with lib; environment = { systemPackages = [ pkgs.nullmailer ]; etc = let - getval = attr: builtins.getAttr attr cfg.config; - attrs = builtins.attrNames cfg.config; - remotesFilter = if cfg.remotesFile != null - then (attr: attr != "remotes") - else (_: true); - optionalRemotesFileLink = if cfg.remotesFile != null - then { "nullmailer/remotes".source = cfg.remotesFile; } - else {}; - attrs' = builtins.filter (attr: (! isNull (getval attr)) && (remotesFilter attr)) attrs; + validAttrs = filterAttrs (name: value: value != null) cfg.config; in - (foldl' (as: attr: as // { "nullmailer/${attr}".text = getval attr; }) {} attrs') - // optionalRemotesFileLink; + (foldl' (as: name: as // { "nullmailer/${name}".text = validAttrs.${name}; }) {} (attrNames validAttrs)) + // optionalAttrs (cfg.remotesFile != null) { "nullmailer/remotes".source = cfg.remotesFile; }; }; users = { |