cluster/containers/dovecot.nix
main 74fcc1a37a
Email changes, enable sieve in Dovecot
Signed-off-by: main <magic_rb@redalder.org>
2022-11-28 00:49:58 +01:00

93 lines
2.6 KiB
Nix

{ nglib, nixpkgs }:
nglib.makeSystem {
system = "x86_64-linux";
name = "ra-systems-dovecot";
inherit nixpkgs;
config = ({ pkgs, config, nglib, lib, ... }:
{
config = {
dumb-init = {
enable = true;
type.services = {};
};
services.dovecot = {
enable = true;
package = pkgs.dovecot;
config = {
protocols = "imap lmtp";
# auth
ssl = "no";
disable_plaintext_auth = "no";
auth_mechanisms = "plain login";
mail_location = "maildir:/maildir/%u";
protocol."imap" = { };
protocol."lmtp" = {
mail_plugins = [ "sieve" ];
};
plugin."" = {
sieve = pkgs.writeText "filter.sieve" ''
require "variables";
require "fileinto";
if header :matches "X-MAILBOX" "*" {
set "DESIRED_MAILBOX" "''${0}";
}
fileinto "''${DESIRED_MAILBOX}";
'';
};
mail_plugin_dir = pkgs.symlinkJoin {
name = "dovecot-modules";
paths = map (pkg: "${pkg}/lib/dovecot") ([ pkgs.dovecot pkgs.dovecot_pigeonhole ]);
};
# Optimizations:
# dotlock_use_excl = true;
maildir_copy_with_hardlinks = true;
lda_mailbox_autocreate = "yes";
lmtp_save_to_detail_mailbox = "yes";
service."lmtp" = {
inet_listener."lmtp" = {
address = [ "127.0.0.1" ];
port = 24;
};
};
service."imap-login" = {
inet_listener."imap" = {
port = 143;
};
# inet_listener."imaps" = {
# port = 993;
# ssl = "yes";
# };
};
# Authentication configuration:
auth_debug = true;
log_path = "/proc/self/fd/1";
info_log_path = "/proc/self/fd/1";
debug_log_path = "/proc/self/fd/1";
passdb."" = {
driver = "passwd-file";
args = "scheme=plain-md5 username_format=%u /secrets/passwd.dovecot";
};
userdb."" = {
driver = "passwd-file";
args = "username_format=%u /secrets/passwd.dovecot";
};
};
};
};
});
}