Skip to content

Commit

Permalink
nullmailer: simplify config generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Mic92 committed Sep 28, 2017
1 parent e741cc4 commit 91eb6cf
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions nixos/modules/services/mail/nullmailer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 91eb6cf

Please sign in to comment.