{ pkgs, ... }: let mailBaseConfig = { configName, address, userName ? address, host, displayName, extraMailboxes ? [], enableDefaultMailboxes ? true, neomuttExtraConfig ? "", } : let defaultMailboxes = if enableDefaultMailboxes then /* `tree ~/Maildir/vbrandl/ -l -d -I "Archive|cur|new|tmp|certs|.notmuch" -afin --noreport | awk '{if(NR>1)print}' | tr '\n' ' '` */ [ "Drafts" "Junk" "Sent" "Trash" ] else []; mailboxes = defaultMailboxes ++ extraMailboxes; in { address = address; userName = userName; realName = displayName; imap.host = host; smtp.host = host; passwordCommand = "${pkgs.libsecret}/bin/secret-tool lookup email ${address}"; signature = { text = displayName; showSignature = "append"; }; aerc = { enable = true; extraAccounts = { pgp-opportunistic-encrypt = true; pgp-autosign = true; }; }; imapnotify = { enable = true; /* TODO: which boxes? */ boxes = [ "Inbox" ]; onNotify = "${pkgs.isync}/bin/mbsync ${configName}"; onNotifyPost = "${pkgs.libnotify}/bin/notify-send -a mail '${configName}: new in %s'"; }; mbsync = { enable = true; /* sync changes to maildir in both directions */ create = "both"; expunge = "both"; remove = "both"; }; msmtp.enable = true; neomutt = { enable = true; extraMailboxes = mailboxes; extraConfig = '' # use encrypted headers set crypt_protected_headers_write = yes '' + neomuttExtraConfig; }; notmuch = { enable = true; neomutt.virtualMailboxes = [ { name = "My INBOX"; query = "tag:inbox"; } { name = "Unread"; query = "tag:unread"; } ]; }; }; in { home.packages = with pkgs; [ libsecret libnotify urlscan ]; home.file.mailcap = { target = ".mailcap"; source = ./mailcap; }; programs.password-store.enable = true; programs.aerc = { enable = true; extraConfig = builtins.readFile ./aerc/aerc.conf; /* { */ /* general = { */ /* unsafe-accounts-conf = true; */ /* }; */ /* }; */ extraBinds = builtins.readFile ./aerc/binds.conf; }; services.mbsync.enable = true; programs.mbsync = { enable = true; package = pkgs.writeShellScriptBin "mbsync" '' ${pkgs.isync}/bin/mbsync $@ ${pkgs.notmuch}/bin/notmuch new ''; }; services.imapnotify.enable = true; programs.notmuch = { enable = true; }; programs.neomutt = { enable = true; sidebar.enable = true; extraConfig = builtins.readFile ./neomutt/neomuttrc; /* vimKeys = true; */ macros = [ { map = [ "pager" "index" ]; key = "B"; action = "|urlscan\\n"; } /*{ map = [ "pager" "index" ]; key = "dd"; action = ":set delete = yes\\nN"; }*/ ]; binds = [ /* sidebar */ { map = [ "attach" "browser" "index" ]; key = "J"; action = "sidebar-next"; } { map = [ "attach" "browser" "index" ]; key = "K"; action = "sidebar-prev"; } { map = [ "attach" "browser" "index" ]; key = "O"; action = "sidebar-open"; } /* moving around */ { map = [ "attach" "browser" "index" ]; key = "j"; action = "next-entry"; } { map = [ "attach" "browser" "index" ]; key = "k"; action = "previous-entry"; } { map = [ "attach" "browser" "index" ]; key = "g"; action = "noop"; } { map = [ "attach" "browser" "index" ]; key = "gg"; action = "first-entry"; } { map = [ "attach" "browser" "index" ]; key = "G"; action = "last-entry"; } { map = [ "attach" "browser" "index" ]; key = "n"; action = "next-unread"; } { map = [ "pager" ]; key = "g"; action = "noop"; } { map = [ "pager" ]; key = "gg"; action = "top"; } { map = [ "pager" ]; key = "G"; action = "bottom"; } { map = [ "pager" ]; key = "k"; action = "previous-line"; } { map = [ "pager" ]; key = "j"; action = "next-line"; } /* deletion */ { map = [ "pager" "index" ]; key = "d"; action = "noop"; } { map = [ "pager" "index" ]; key = "dd"; action = "delete-message"; } /* TODO: mark as new? */ { map = [ "browser" "pager" "index" ]; key = "U"; action = "toggle-new"; } { map = [ "browser" "pager" "index" ]; key = "n"; action = "search-next"; } { map = [ "browser" "pager" "index" ]; key = "N"; action = "search-opposite"; } /* threads */ { map = [ "pager" "index" ]; key = "dT"; action = "delete-thread"; } { map = [ "pager" "index" ]; key = "dt"; action = "delete-subthread"; } { map = [ "pager" "index" ]; key = "gt"; action = "next-thread"; } { map = [ "pager" "index" ]; key = "gT"; action = "previous-thread"; } { map = [ "index" ]; key = "za"; action = "collapse-thread"; } { map = [ "index" ]; key = "zA"; action = "collapse-all"; } ]; }; programs.msmtp.enable = true; accounts.email.accounts = let aliases = "mail(\\+.*)?@vbrandl.net"; in { vbrandl = ( mailBaseConfig { configName = "vbrandl"; address = "mail@vbrandl.net"; host = "mail.vbrandl.net"; displayName = "Valentin Brandl"; extraMailboxes = [ "Archive" "Banking" "Conversation" "Covid" "Dev" "Memberships" "Newsletter" "Orders" "Rent" "Social" "Support" "Travel" "Uni" "Work" ]; /* #set use_from = yes */ /* #set envelope_from = true */ neomuttExtraConfig = '' # TODO: reply with tagged mail set reverse_name = yes alternates '${aliases}' ''; }) // { primary = true; aliases = [ aliases ]; gpg = { encryptByDefault = true; signByDefault = true; key = "1FFE431282F4B8CC0A7579167FB009175885FC76"; }; }; riseup = ( mailBaseConfig { configName = "riseup"; address = "vbrandl@riseup.net"; host = "mail.riseup.net"; displayName = "Valentin Brandl"; extraMailboxes = [ "Archive" "Banking" "Contracts" "Conversation" "Dev" "Mailinglists" "Newsletter" "Orders" "Social" "Support" "Travel" "Uni" ]; }) // { userName = "vbrandl"; gpg = { encryptByDefault = true; signByDefault = true; key = "1FFE431282F4B8CC0A7579167FB009175885FC76"; }; }; }; }