Add `forwards` option
This option allow to forward mails to external addresses.
This commit is contained in:
parent
5cd6f8e7b3
commit
24600377af
18
default.nix
18
default.nix
|
@ -218,6 +218,24 @@ in
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
forwards = mkOption {
|
||||||
|
type = with types; attrsOf (either (listOf str) str);
|
||||||
|
default = {};
|
||||||
|
example = {
|
||||||
|
"user@example.com" = "user@elsewhere.com";
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
To forward mails to an external address. For instance,
|
||||||
|
the value {`"user@example.com" = "user@elsewhere.com";}`
|
||||||
|
means that mails to `user@example.com` are forwarded to
|
||||||
|
`user@elsewhere.com`. The difference with the
|
||||||
|
`extraVirtualAliases` option is that `user@elsewhere.com`
|
||||||
|
can't send mail as `user@example.com`. Also, this option
|
||||||
|
allows to forward mails to external addresses.
|
||||||
|
'';
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
rejectSender = mkOption {
|
rejectSender = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
example = [ "@example.com" "spammer@example.net" ];
|
example = [ "@example.com" "spammer@example.net" ];
|
||||||
|
|
|
@ -37,15 +37,7 @@ let
|
||||||
cfg.loginAccounts);
|
cfg.loginAccounts);
|
||||||
|
|
||||||
# extra_valiases_postfix :: [ String ]
|
# extra_valiases_postfix :: [ String ]
|
||||||
extra_valiases_postfix =
|
extra_valiases_postfix = attrsToAliasList cfg.extraVirtualAliases;
|
||||||
(map
|
|
||||||
(from:
|
|
||||||
let to = cfg.extraVirtualAliases.${from};
|
|
||||||
aliasList = (l: let aliasStr = builtins.foldl' (x: y: x + y + ", ") "" l;
|
|
||||||
in builtins.substring 0 (builtins.stringLength aliasStr - 2) aliasStr);
|
|
||||||
in if (builtins.isList to) then "${from} " + (aliasList to)
|
|
||||||
else "${from} ${to}")
|
|
||||||
(builtins.attrNames cfg.extraVirtualAliases));
|
|
||||||
|
|
||||||
# all_valiases_postfix :: [ String ]
|
# all_valiases_postfix :: [ String ]
|
||||||
all_valiases_postfix = valiases_postfix ++ extra_valiases_postfix;
|
all_valiases_postfix = valiases_postfix ++ extra_valiases_postfix;
|
||||||
|
@ -56,6 +48,16 @@ let
|
||||||
(lib.filter (acct: acct.sendOnly) (lib.attrValues cfg.loginAccounts)));
|
(lib.filter (acct: acct.sendOnly) (lib.attrValues cfg.loginAccounts)));
|
||||||
denied_recipients_file = builtins.toFile "denied_recipients" (lib.concatStringsSep "\n" denied_recipients_postfix);
|
denied_recipients_file = builtins.toFile "denied_recipients" (lib.concatStringsSep "\n" denied_recipients_postfix);
|
||||||
|
|
||||||
|
# attrsToAliasList :: Map String (Either String [ String ]) -> [ String ]
|
||||||
|
attrsToAliasList = aliases:
|
||||||
|
let
|
||||||
|
toList = to: if builtins.isList to then to else [to];
|
||||||
|
in lib.mapAttrsToList
|
||||||
|
(from: to: "${from} " + (lib.concatStringsSep ", " (toList to)))
|
||||||
|
aliases;
|
||||||
|
|
||||||
|
# forwards :: [ String ]
|
||||||
|
forwards = attrsToAliasList cfg.forwards;
|
||||||
|
|
||||||
# valiases_file :: Path
|
# valiases_file :: Path
|
||||||
valiases_file = builtins.toFile "valias"
|
valiases_file = builtins.toFile "valias"
|
||||||
|
@ -136,7 +138,7 @@ in
|
||||||
sslKey = keyPath;
|
sslKey = keyPath;
|
||||||
enableSubmission = true;
|
enableSubmission = true;
|
||||||
virtual =
|
virtual =
|
||||||
(lib.concatStringsSep "\n" (all_valiases_postfix ++ catchAllPostfix));
|
(lib.concatStringsSep "\n" (all_valiases_postfix ++ catchAllPostfix ++ forwards));
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
# Extra Config
|
# Extra Config
|
||||||
|
|
Loading…
Reference in New Issue