From d81e29de506186892ecf11ae7b0f9332172f12e7 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 16 Jan 2020 21:42:57 +1300 Subject: [PATCH] mail: use neomutt instead of alot --- configs/workhorse/mail-fetcher.nix | 6 +- system/desktop/mail-stuff.nix | 135 ++++++++++++++++++++++++++++- 2 files changed, 139 insertions(+), 2 deletions(-) diff --git a/configs/workhorse/mail-fetcher.nix b/configs/workhorse/mail-fetcher.nix index 6fa9a75..86da1fb 100644 --- a/configs/workhorse/mail-fetcher.nix +++ b/configs/workhorse/mail-fetcher.nix @@ -1,5 +1,9 @@ # fetches mails for me { lib, pkgs, config, ... }: { + + + backup.all.restic.dirs = [ config.users.users.mailUser.home ]; + users.users.mailUser = { isNormalUser = true; description = "collects mails for me"; @@ -330,7 +334,7 @@ tags = [ "+jobs" "-inbox" ]; } { - query = "from:seek.com.au"; + query = "from:seek.com.au or from:seek.co.nz"; tags = [ "+jobs" ]; } { diff --git a/system/desktop/mail-stuff.nix b/system/desktop/mail-stuff.nix index 16b915b..e3e6db3 100644 --- a/system/desktop/mail-stuff.nix +++ b/system/desktop/mail-stuff.nix @@ -2,6 +2,7 @@ let passcmd = id: "${pkgs.pass}/bin/pass ${id}"; ticks = "''"; + in { # Maildir <-> Server communication # -------------------------------- @@ -373,7 +374,139 @@ in { text/html; ${pkgs.elinks}/bin/elinks -dump ; copiousoutput; ''; + home-manager.users.mainUser.home.file.".muttrc".text = '' + # gpg + set crypt_use_gpgme=yes + set crypt_autosign=yes + set crypt_verify_sig=yes + set crypt_replysign=yes + set crypt_replyencrypt=yes + set crypt_replysignencrypted=yes + set crypt_autoencrypt = yes + + set pgp_check_gpg_decrypt_status_fd + set pgp_use_gpg_agent = yes + set pgp_self_encrypt = yes # needs default key + set pgp_default_key = 42AC51C9482D0834CF488AF1389EC2D64AC71EAC + + # read html mails + auto_view text/html + set mailcap_path = ~/.mailcap + + # notmuch + set nm_default_uri="notmuch://$HOME/Maildir" # path to the maildir + set nm_record = yes + set nm_record_tags = "-inbox me archive" + set virtual_spoolfile=yes # enable virtual folders + + set sendmail=${pkgs.writers.writeBash "msmtp" '' + ${pkgs.coreutils}/bin/tee >(${pkgs.notmuch}/bin/notmuch insert --create-folder +sent) | \ + ${pkgs.msmtp}/bin/msmtp "$@" + ''} + + set from="contact@ingolf-wagner.de" + #alternates ^.*@ingolf-wagner\.de$ ^.*@.*\.r$ + set use_from=yes + set envelope_from=yes + set reverse_name + + set sort=threads + + set index_format="${pkgs.writers.writeDash "mutt-index" '' + # http://www.mutt.org/doc/manual/#formatstrings + recipent="$(echo $1 | sed 's/[^,]*<\([^>]*\)[^,]*/ \1/g')" + # output to mutt + # V + echo "%4C %Z %?GI?%GI& ? %[%y-%m-%d %H:%M] %-20.20a %?M?(%3M)& ? %s %> $recipent %?g?%g?%" + # args to mutt-index dash script + # V + ''} %r |" + + virtual-mailboxes "INBOX" "notmuch://?query=(tag:inbox or (tag:sent and not tag:archive)) AND NOT tag:discourse" + virtual-mailboxes "Unread" "notmuch://?query=tag:unread" + virtual-mailboxes "Discourse" "notmuch://?query=tag:discourse" + virtual-mailboxes "Starred" "notmuch://?query=tag:flagged" + virtual-mailboxes "Archive" "notmuch://?query=tag:archive" + virtual-mailboxes "Sent" "notmuch://?query=tag:sent" + virtual-mailboxes "Junk" "notmuch://?query=tag:junk" + virtual-mailboxes "All" "notmuch://?query=*" + + tag-transforms "junk" "k" \ + "unread" "u" \ + "replied" "↻" \ + "TODO" "T" \ + + # notmuch bindings + macro index \\\\ "" # looks up a hand made query + macro index + "+*\n" # tag as starred + macro index - "-*\n" # tag as unstarred + + + # keys bindings + # ------------- + #killed + bind index d noop + bind pager d noop + + bind index S noop + bind index s noop + bind pager S noop + bind pager s noop + macro index S "-inbox -unread +junk\n" # tag as Junk mail + macro index s "-junk\n" # tag as Junk mail + macro pager S "-inbox -unread +junk\n" # tag as Junk mail + macro pager s "-junk\n" # tag as Junk mail + + + bind index A noop + bind index a noop + bind pager A noop + bind pager a noop + macro index A "+archive -unread -inbox\n" # tag as Archived + macro index a "-archive\n" # tag as Archived + macro pager A "+archive -unread -inbox\n" # tag as Archived + macro pager a "-archive\n" # tag as Archived + + bind index U noop + bind index u noop + bind pager U noop + bind pager u noop + macro index U "+unread\n" + macro index u "-unread\n" + macro pager U "+unread\n" + macro pager u "-unread\n" + + bind index t noop + bind pager t noop + macro index t "" # set tags manual + macro pager t "" # set tags manual + + # top index bar in email view + set pager_index_lines=7 + # top_index_bar toggle + macro pager ,@1 " set pager_index_lines=0; macro pager ] ,@2 'Toggle indexbar" + macro pager ,@2 " set pager_index_lines=3; macro pager ] ,@3 'Toggle indexbar" + macro pager ,@3 " set pager_index_lines=7; macro pager ] ,@1 'Toggle indexbar" + macro pager ] ,@1 'Toggle indexbar + + # sidebar + # ------- + set sidebar_width = 20 + set sidebar_visible = yes # set to "no" to disable sidebar view at startup + color sidebar_new yellow default + # sidebar bindings + bind index sidebar-prev # got to previous folder in sidebar + bind index sidebar-next # got to next folder in sidebar + bind index sidebar-open # open selected folder from sidebar + + # sidebar toggle + #macro index,pager ,@) " set sidebar_visible=no; macro index,pager [ ,@( 'Toggle sidebar'" + #macro index,pager ,@( " set sidebar_visible=yes; macro index,pager [ ,@) 'Toggle sidebar'" + #macro index,pager [ ,@( 'Toggle sidebar' # toggle the sidebar + ''; + environment.systemPackages = let + mailSync = pkgs.writeShellScriptBin "mail-sync" '' ${pkgs.muchsync}/bin/muchsync mailfetcher@workhorse.private --nonew ''; @@ -389,6 +522,6 @@ in { ${mailSend}/bin/mail-send ${mailSync}/bin/mail-sync ''; - in [ pkgs.notmuch pkgs.alot pkgs.muchsync mail mailSync mailView mailSend ]; + in [ pkgs.notmuch pkgs.alot pkgs.muchsync mail mailSync mailView mailSend pkgs.neomutt ]; }