Dovecot: Mailbox config + hierarchy separator + FS layout.
- Factored mailbox config into its own option. - Added hierarchy separator option. - Added option for using FS layout.
This commit is contained in:
parent
82823a4085
commit
43d36d9b76
2 changed files with 66 additions and 23 deletions
58
default.nix
58
default.nix
|
@ -201,6 +201,64 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useFsLayout = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Sets whether dovecot should organize mail in subdirectories:
|
||||||
|
|
||||||
|
- /var/vmail/example.com/user/.folder.subfolder/ (default layout)
|
||||||
|
- /var/vmail/example.com/user/folder/subfolder/ (FS layout)
|
||||||
|
|
||||||
|
See https://wiki2.dovecot.org/MailboxFormat/Maildir for details.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
hierarchySeparator = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
default = ".";
|
||||||
|
description = ''
|
||||||
|
The hierarchy separator for mailboxes used by dovecot for the namespace 'inbox'.
|
||||||
|
Dovecot defaults to "." but recommends "/".
|
||||||
|
This affects how mailboxes appear to mail clients and sieve scripts.
|
||||||
|
For instance when using "." then in a sieve script "example.com" would refer to the mailbox "com" in the parent mailbox "example".
|
||||||
|
This does not determine the way your mails are stored on disk.
|
||||||
|
See https://wiki.dovecot.org/Namespaces for details.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
mailboxes = mkOption {
|
||||||
|
description = ''
|
||||||
|
The mailboxes for dovecot.
|
||||||
|
Depending on the mail client used it might be necessary to change some mailbox's name.
|
||||||
|
'';
|
||||||
|
default = [
|
||||||
|
{
|
||||||
|
name = "Trash";
|
||||||
|
auto = "no";
|
||||||
|
specialUse = "Trash";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
name = "Junk";
|
||||||
|
auto = "subscribe";
|
||||||
|
specialUse = "Junk";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
name = "Drafts";
|
||||||
|
auto = "subscribe";
|
||||||
|
specialUse = "Drafts";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
name = "Sent";
|
||||||
|
auto = "subscribe";
|
||||||
|
specialUse = "Sent";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
certificateScheme = mkOption {
|
certificateScheme = mkOption {
|
||||||
type = types.enum [ 1 2 3 ];
|
type = types.enum [ 1 2 3 ];
|
||||||
default = 2;
|
default = 2;
|
||||||
|
|
|
@ -21,11 +21,13 @@ with (import ./common.nix { inherit config lib; });
|
||||||
let
|
let
|
||||||
cfg = config.mailserver;
|
cfg = config.mailserver;
|
||||||
|
|
||||||
# maildir in format "/${domain}/${user}"
|
maildirLayoutAppendix = lib.optionalString cfg.useFsLayout ":LAYOUT=fs";
|
||||||
dovecot_maildir = "maildir:${cfg.mailDirectory}/%d/%n";
|
|
||||||
|
|
||||||
dovecotVersion = builtins.fromJSON
|
dovecotVersion = builtins.fromJSON
|
||||||
(builtins.readFile (pkgs.callPackage ./dovecot-version.nix {}));
|
(builtins.readFile (pkgs.callPackage ./dovecot-version.nix {}));
|
||||||
|
|
||||||
|
# maildir in format "/${domain}/${user}"
|
||||||
|
dovecotMaildir = "maildir:${cfg.mailDirectory}/%d/%n${maildirLayoutAppendix}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = with cfg; lib.mkIf enable {
|
config = with cfg; lib.mkIf enable {
|
||||||
|
@ -37,7 +39,7 @@ in
|
||||||
enableQuota = true;
|
enableQuota = true;
|
||||||
mailGroup = vmailGroupName;
|
mailGroup = vmailGroupName;
|
||||||
mailUser = vmailUserName;
|
mailUser = vmailUserName;
|
||||||
mailLocation = dovecot_maildir;
|
mailLocation = dovecotMaildir;
|
||||||
sslServerCert = certificatePath;
|
sslServerCert = certificatePath;
|
||||||
sslServerKey = keyPath;
|
sslServerKey = keyPath;
|
||||||
enableLmtp = true;
|
enableLmtp = true;
|
||||||
|
@ -55,6 +57,8 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mailboxes = cfg.mailboxes;
|
||||||
|
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
#Extra Config
|
#Extra Config
|
||||||
${lib.optionalString debug ''
|
${lib.optionalString debug ''
|
||||||
|
@ -102,27 +106,8 @@ in
|
||||||
auth_mechanisms = plain login
|
auth_mechanisms = plain login
|
||||||
|
|
||||||
namespace inbox {
|
namespace inbox {
|
||||||
|
separator = ${cfg.hierarchySeparator}
|
||||||
inbox = yes
|
inbox = yes
|
||||||
|
|
||||||
mailbox "Trash" {
|
|
||||||
auto = no
|
|
||||||
special_use = \Trash
|
|
||||||
}
|
|
||||||
|
|
||||||
mailbox "Junk" {
|
|
||||||
auto = subscribe
|
|
||||||
special_use = \Junk
|
|
||||||
}
|
|
||||||
|
|
||||||
mailbox "Drafts" {
|
|
||||||
auto = subscribe
|
|
||||||
special_use = \Drafts
|
|
||||||
}
|
|
||||||
|
|
||||||
mailbox "Sent" {
|
|
||||||
auto = subscribe
|
|
||||||
special_use = \Sent
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin {
|
plugin {
|
||||||
|
|
Loading…
Reference in a new issue