{ config, pkgs, lib, ... }: let makeConfig = accountName: '' unset reverse_name unset smime_is_default set my_account='${ accountName }' macro index,pager / "tag:${ accountName } " unalternates * set nm_record_tags = "+sent -inbox -unread +${ accountName }"; set my_signature = ${ pkgs.writeText "signature.txt" config.accounts.email.accounts.${accountName}.signature.text } set status_format = "— [ %r ] $my_account %f (%lB) %>— %m messages%?n? [ %n new ]?%?d? [ %d to delete ]?%?t? [ %t tagged ]? —" source colors.neomuttrc ''; makeAccount = accountName: { signature.showSignature = "append"; smtp.tls.useStartTls = true; msmtp.enable = true; mbsync = { enable = true; create = "maildir"; expunge = "both"; }; neomutt = { enable = true; sendMailCommand = "${lib.getExe pkgs.msmtp} -a ${ accountName }"; }; notmuch = { enable = true; neomutt = { virtualMailboxes = [ { name = "Inbox"; query = "tag:${ accountName } and tag:inbox"; } { name = "Archive"; query = "tag:${ accountName } and not tag:sent and not tag:draft"; } { name = "Sent"; query = "tag:${ accountName } and tag:sent"; } { name = "Drafts"; query = "tag:${ accountName } and tag:draft"; } { name = "Spam"; query = "tag:${ accountName } and tag:spam"; } { name = "Trash"; query = "tag:${ accountName } and tag:trash"; } ]; }; }; }; mailcap_path = pkgs.writeText "neomutt_mailcap" '' application/pdf; zathura %s multipart; xdg-open %s text/html; firefox %s; description=HTML Text; nametemplate=%s.html; needsterminal text/html; w3m -v -F -T text/html -dump %s; copiousoutput text/calendar; khal import %s text; neomutt %s application; xdg-open %s image; xdg-open %s video; xdg-open %s audio; xdg-open %s message; xdg-open %s model; xdg-open %s ''; in { programs.mu.enable = true; accounts.email = { maildirBasePath = "${config.xdg.dataHome}/mail"; accounts = { gu = { name, ... }: lib.attrsets.recursiveUpdate (makeAccount name) { primary = true; address = "straube@geo.uni-frankfurt.de"; realName = "Till Straube"; imap.host = "imap.server.uni-frankfurt.de"; smtp.host = "smtpauth.rz.uni-frankfurt.de"; userName = "tstraube"; passwordCommand = "pass uni/hrz"; signature = { text = '' Dr. Till Straube (he/him) Dept. of Human Geography Goethe University Frankfurt ''; }; neomutt = { extraConfig = makeConfig name + '' color status blue default color index blue default '~N' alternates ^tstraube@(em|rz)?.uni-frankfurt.de$ set smime_is_default ''; }; }; t9e = { name, ... }: lib.attrsets.recursiveUpdate (makeAccount name) { address = "till.straube@t9e.me"; realName = "Till Straube"; imap.host = "arielle.ktiu.net"; smtp.host = "arielle.ktiu.net"; userName = "till.straube@t9e.me"; signature.text = '' Till Straube (he/him) PGP key: https://keys.openpgp.org/search?q=till.straube@t9e.me ''; neomutt = { extraConfig = makeConfig name + '' color status green default color index green default '~N' alternates @t9e.me$ @ktiu.net$ ^(tillkowski|till.straube)@gmail.com$ set reverse_name ''; }; msmtp.extraConfig.port = "587"; passwordCommand = "pass accounts/ktiu-imap"; }; ksh = { name, ... }: lib.attrsets.recursiveUpdate (makeAccount name) { address = "kein_schlussstrich_hessen@systemli.org"; realName = "Kein Schlussstrich Hessen"; imap.host = "mail.systemli.org"; smtp.host = "mail.systemli.org"; userName = "kein_schlussstrich_hessen@systemli.org"; signature.text = '' Kein Schlussstrich Hessen PGP Key: https://keys.openpgp.org/search?q=kein_schlussstrich_hessen@systemli.org ''; neomutt = { extraConfig = makeConfig name + '' color status red default color index red default '~N' ''; }; passwordCommand = "pass ksh/systemli"; }; }; }; programs.msmtp.enable = true; programs.mbsync.enable = true; programs.notmuch = { enable = true; search.excludeTags = [ "trash" "spam" ]; new.tags = [ "new" "unread" ]; hooks = { preNew = '' notmuch tag +draft -- 'folder:"/\/Drafts$/"' mbsync --all ''; postNew = '' notmuch tag +gu -- tag:new path:gu/** notmuch tag +t9e -- tag:new path:t9e/** notmuch tag +ksh -- tag:new path:ksh/** notmuch tag +inbox -- tag:new 'folder:"/\/Inbox$/"' notmuch tag +sent -unread -- tag:new 'folder:"/\/Sent$/"' notmuch tag +trash -unread -- tag:new 'folder:"/\/Trash$/"' notmuch tag +draft -unread -- tag:new 'folder:"/\/Drafts$/"' notmuch tag +spam -- tag:new 'folder:"/\/Spam$/"' notmuch tag +spam -- tag:new 'folder:"/\/Junk$/"' notmuch tag -new -- tag:new ''; }; }; programs.neomutt = { enable = true; vimKeys = true; changeFolderWhenSourcingAccount = true; editor = "nvim -c 'call woof#init#Init()'"; sort = "reverse-date-received"; unmailboxes = true; settings = { abort_noattach = "ask-yes"; abort_noattach_regex = "\"(attach|enclosed|anbei|anhängen|angehängt|anhang|anhänge|hängt an)\""; auto_edit = "no"; beep = "no"; confirm_append = "no"; crypt_auto_sign = "yes"; crypt_replyencrypt = "yes"; crypt_replysign = "yes"; crypt_replysignencrypted = "yes"; crypt_verify_sig = "yes"; edit_headers = "yes"; forward_attachments = "yes"; forward_format = "\"Fwd: %s\""; forward_quote = "yes"; help = "no"; include = "yes"; mail_check_stats = "yes"; mailcap_path = "${ mailcap_path }"; mark_old = "no"; markers = "no"; mbox_type = "Maildir"; menu_scroll = "yes"; mime_type_query_command = "\"file -b --mime-type %s\""; nm_record = "yes"; pager_context = "3"; pager_index_lines = "5"; pager_stop = "yes"; query_command= "\"khard email --parsable '%s'\""; recall = "no"; resume_draft_files = "yes"; reverse_real_name = "no"; shell = "/bin/sh"; sleep_time = "0"; smart_wrap = "yes"; status_chars = "✔↻٪A"; tilde = "yes"; use_envelope_from = "yes"; virtual_spool_file = "yes"; wait_key = "no"; }; binds = [ { key = "m"; map = [ "index" "pager" ]; action = "noop"; } { key = "k"; map = [ "pager" ]; action = "previous-entry"; } { key = "j"; map = [ "pager" ]; action = "next-entry"; } { key = ""; map = [ "index" ]; action = "display-message"; } { key = ""; map = [ "index" ]; action = "entire-thread"; } { key = "gf"; map = [ "index" "pager" ]; action = "change-folder"; } { key = ""; map = [ "editor" ]; action = "complete-query"; } { key = "P"; map = [ "compose" ]; action = "pgp-menu"; } { key = "p"; map = [ "compose" ]; action = "postpone-message"; } ]; macros = [ { key = "gu"; map = [ "index" "pager" ]; action = "tag:dummy:source ${config.xdg.configHome}/neomutt/gug!"; } { key = "gm"; map = [ "index" "pager" ]; action = "tag:dummy:source ${config.xdg.configHome}/neomutt/t9eg!"; } { key = "gk"; map = [ "index" "pager" ]; action = "tag:dummy:source ${config.xdg.configHome}/neomutt/kshg!"; } { key = "Y"; map = [ "index" "pager" ]; action = ""; } { key = "y"; map = [ "index" "pager" ]; action = "-inbox -unread -spam -trash"; } { key = "J"; map = [ "index" "pager" ]; action = "+spam -inbox -unread -trash"; } { key = "I"; map = [ "index" "pager" ]; action = "+inbox -old -spam -trash"; } { key = "Y"; map = [ "index" "pager" ]; action = ""; } { key = "dd"; map = [ "index" "pager" ]; action = "+trash -inbox -unread -spam"; } { key = "g!"; map = [ "index" "pager" ]; action = "Inbox"; } { key = "g<"; map = [ "index" "pager" ]; action = "Sent"; } { key = "g>"; map = [ "index" "pager" ]; action = "Archive"; } { key = "gj"; map = [ "index" "pager" ]; action = "Spam"; } { key = "gd"; map = [ "index" "pager" ]; action = "Drafts"; } { key = "gt"; map = [ "index" "pager" ]; action = "Trash"; } { key = "go"; map = [ "index" "pager" ]; action = "notmuch new"; } { key = "V"; map = ["index" "pager"]; action = "html"; } { key = "mar"; map = [ "index" "pager" ]; action = "newn*"; } { key = "A"; map = [ "index" "pager" ]; action = "khard add-email --vcard-version=4.0"; } { key = "S"; map = [ "index" "pager" ]; action = "ripmime -i - -d ~/tmp && rm ~/tmp/textfile*"; } { key = "gb"; map = [ "index" "pager" ]; action = "urlscan"; } { key = "I"; map = [ "compose" ]; action = "`tmpfile=$(mktemp -u --suffix .png -t XXXXXXXXXXXX -p ~/tmp) && wl-paste -t image/png > \"$tmpfile\" && echo \"$tmpfile\"`"; } { key = "p"; map = [ "compose" ]; action = ""; } { key = "c"; map = [ "index" "pager" ]; action = "set signature=$my_signature"; } { key = "r"; map = [ "index" "pager" ]; action = "unset signature"; } { key = "a"; map = [ "index" "pager" ]; action = "unset signature"; } { key = "f"; map = [ "index" "pager" ]; action = "unset signature"; } { key = "l"; map = [ "index" "pager" ]; action = "unset signature"; } ]; extraConfig = builtins.readFile ../../dotfiles/neomutt/config.neomuttrc; }; xdg.configFile."neomutt/colors.neomuttrc".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/dotfiles/neomutt/colors.neomuttrc"; xdg.configFile."neomutt/bindings.neomuttrc".source = config.lib.file.mkOutOfStoreSymlink "/etc/nixos/dotfiles/neomutt/bindings.neomuttrc"; programs.neovim.plugins = with pkgs.vimPlugins; [ { plugin = vim-pathogen; type = "viml"; config = "execute pathogen#infect()"; } ]; xdg.configFile."nvim/bundle/woof-vim" = { source = config.lib.file.mkOutOfStoreSymlink "/home/till/devel/woof-vim"; recursive = true; }; }