nixos/modules/services/mail/dovecot.nix: nixpkgs-fmt
This commit is contained in:
parent
56f9c51b05
commit
7a40ced06b
@ -18,13 +18,20 @@ let
|
||||
mail_plugins = $mail_plugins ${concatStringsSep " " cfg.mailPlugins.globally.enable}
|
||||
''
|
||||
|
||||
(concatStringsSep "\n" (mapAttrsToList (protocol: plugins: ''
|
||||
(
|
||||
concatStringsSep "\n" (
|
||||
mapAttrsToList (
|
||||
protocol: plugins: ''
|
||||
protocol ${protocol} {
|
||||
mail_plugins = $mail_plugins ${concatStringsSep " " plugins.enable}
|
||||
}
|
||||
'') cfg.mailPlugins.perProtocol))
|
||||
''
|
||||
) cfg.mailPlugins.perProtocol
|
||||
)
|
||||
)
|
||||
|
||||
(if cfg.sslServerCert == null then ''
|
||||
(
|
||||
if cfg.sslServerCert == null then ''
|
||||
ssl = no
|
||||
disable_plaintext_auth = no
|
||||
'' else ''
|
||||
@ -33,7 +40,8 @@ let
|
||||
${optionalString (cfg.sslCACert != null) ("ssl_ca = <" + cfg.sslCACert)}
|
||||
ssl_dh = <${config.security.dhparams.params.dovecot2.path}
|
||||
disable_plaintext_auth = yes
|
||||
'')
|
||||
''
|
||||
)
|
||||
|
||||
''
|
||||
default_internal_user = ${cfg.user}
|
||||
@ -53,7 +61,8 @@ let
|
||||
}
|
||||
''
|
||||
|
||||
(optionalString cfg.enablePAM ''
|
||||
(
|
||||
optionalString cfg.enablePAM ''
|
||||
userdb {
|
||||
driver = passwd
|
||||
}
|
||||
@ -62,24 +71,30 @@ let
|
||||
driver = pam
|
||||
args = ${optionalString cfg.showPAMFailure "failure_show_msg=yes"} dovecot2
|
||||
}
|
||||
'')
|
||||
''
|
||||
)
|
||||
|
||||
(optionalString (cfg.sieveScripts != {}) ''
|
||||
(
|
||||
optionalString (cfg.sieveScripts != {}) ''
|
||||
plugin {
|
||||
${concatStringsSep "\n" (mapAttrsToList (to: from: "sieve_${to} = ${stateDir}/sieve/${to}") cfg.sieveScripts)}
|
||||
}
|
||||
'')
|
||||
''
|
||||
)
|
||||
|
||||
(optionalString (cfg.mailboxes != []) ''
|
||||
(
|
||||
optionalString (cfg.mailboxes != []) ''
|
||||
protocol imap {
|
||||
namespace inbox {
|
||||
inbox=yes
|
||||
${concatStringsSep "\n" (map mailboxConfig cfg.mailboxes)}
|
||||
}
|
||||
}
|
||||
'')
|
||||
''
|
||||
)
|
||||
|
||||
(optionalString cfg.enableQuota ''
|
||||
(
|
||||
optionalString cfg.enableQuota ''
|
||||
service quota-status {
|
||||
executable = ${dovecotPkg}/libexec/dovecot/quota-status -p postfix
|
||||
inet_listener {
|
||||
@ -96,7 +111,8 @@ let
|
||||
quota_status_overquota = "552 5.2.2 Mailbox is full"
|
||||
quota_grace = 10%%
|
||||
}
|
||||
'')
|
||||
''
|
||||
)
|
||||
|
||||
cfg.extraConfig
|
||||
];
|
||||
@ -187,7 +203,8 @@ in
|
||||
};
|
||||
|
||||
mailPlugins =
|
||||
let plugins = hint: types.submodule {
|
||||
let
|
||||
plugins = hint: types.submodule {
|
||||
options = {
|
||||
enable = mkOption {
|
||||
type = types.listOf types.str;
|
||||
@ -354,20 +371,21 @@ in
|
||||
|
||||
users.users = {
|
||||
dovenull =
|
||||
{ uid = config.ids.uids.dovenull2;
|
||||
{
|
||||
uid = config.ids.uids.dovenull2;
|
||||
description = "Dovecot user for untrusted logins";
|
||||
group = "dovenull";
|
||||
};
|
||||
} // optionalAttrs (cfg.user == "dovecot2") {
|
||||
dovecot2 =
|
||||
{ uid = config.ids.uids.dovecot2;
|
||||
{
|
||||
uid = config.ids.uids.dovecot2;
|
||||
description = "Dovecot user";
|
||||
group = cfg.group;
|
||||
};
|
||||
} // optionalAttrs (cfg.createMailUser && cfg.mailUser != null) {
|
||||
${cfg.mailUser} =
|
||||
{ description = "Virtual Mail User"; } //
|
||||
optionalAttrs (cfg.mailGroup != null)
|
||||
{ description = "Virtual Mail User"; } // optionalAttrs (cfg.mailGroup != null)
|
||||
{ group = cfg.mailGroup; };
|
||||
};
|
||||
|
||||
@ -405,7 +423,9 @@ in
|
||||
rm -rf ${stateDir}/sieve
|
||||
'' + optionalString (cfg.sieveScripts != {}) ''
|
||||
mkdir -p ${stateDir}/sieve
|
||||
${concatStringsSep "\n" (mapAttrsToList (to: from: ''
|
||||
${concatStringsSep "\n" (
|
||||
mapAttrsToList (
|
||||
to: from: ''
|
||||
if [ -d '${from}' ]; then
|
||||
mkdir '${stateDir}/sieve/${to}'
|
||||
cp -p "${from}/"*.sieve '${stateDir}/sieve/${to}'
|
||||
@ -413,7 +433,9 @@ in
|
||||
cp -p '${from}' '${stateDir}/sieve/${to}'
|
||||
fi
|
||||
${pkgs.dovecot_pigeonhole}/bin/sievec '${stateDir}/sieve/${to}'
|
||||
'') cfg.sieveScripts)}
|
||||
''
|
||||
) cfg.sieveScripts
|
||||
)}
|
||||
chown -R '${cfg.mailUser}:${cfg.mailGroup}' '${stateDir}/sieve'
|
||||
'';
|
||||
};
|
||||
@ -421,17 +443,21 @@ in
|
||||
environment.systemPackages = [ dovecotPkg ];
|
||||
|
||||
assertions = [
|
||||
{ assertion = intersectLists cfg.protocols [ "pop3" "imap" ] != [];
|
||||
{
|
||||
assertion = intersectLists cfg.protocols [ "pop3" "imap" ] != [];
|
||||
message = "dovecot needs at least one of the IMAP or POP3 listeners enabled";
|
||||
}
|
||||
{ assertion = (cfg.sslServerCert == null) == (cfg.sslServerKey == null)
|
||||
{
|
||||
assertion = (cfg.sslServerCert == null) == (cfg.sslServerKey == null)
|
||||
&& (cfg.sslCACert != null -> !(cfg.sslServerCert == null || cfg.sslServerKey == null));
|
||||
message = "dovecot needs both sslServerCert and sslServerKey defined for working crypto";
|
||||
}
|
||||
{ assertion = cfg.showPAMFailure -> cfg.enablePAM;
|
||||
{
|
||||
assertion = cfg.showPAMFailure -> cfg.enablePAM;
|
||||
message = "dovecot is configured with showPAMFailure while enablePAM is disabled";
|
||||
}
|
||||
{ assertion = cfg.sieveScripts != {} -> (cfg.mailUser != null && cfg.mailGroup != null);
|
||||
{
|
||||
assertion = cfg.sieveScripts != {} -> (cfg.mailUser != null && cfg.mailGroup != null);
|
||||
message = "dovecot requires mailUser and mailGroup to be set when sieveScripts is set";
|
||||
}
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user