{ inputs, ... }: { flake.nixngConfigurations.dovecot = inputs.nixng.nglib.makeSystem { system = "x86_64-linux"; name = "ra-systems-dovecot"; inherit (inputs) nixpkgs; config = { pkgs, ... }: { 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 = "/mail-configuration/entry.sieve"; }; 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 username_format=%u /secrets/passwd.dovecot"; }; userdb."" = { driver = "passwd-file"; args = "username_format=%u /secrets/passwd.dovecot"; default_fields = "uid=vmail gid=vmail home=/maildir/%u"; }; }; }; }; }; }; }