mail: use neomutt instead of alot

This commit is contained in:
Ingolf Wagner 2020-01-16 21:42:57 +13:00
parent 58c5f5f428
commit d81e29de50
Signed by: palo
GPG key ID: 76BF5F1928B9618B
2 changed files with 139 additions and 2 deletions

View file

@ -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" ];
}
{

View file

@ -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 \\\\ "<vfolder-from-query>" # looks up a hand made query
macro index + "<modify-labels>+*\n<sync-mailbox>" # tag as starred
macro index - "<modify-labels>-*\n<sync-mailbox>" # 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 "<modify-labels-then-hide>-inbox -unread +junk\n" # tag as Junk mail
macro index s "<modify-labels>-junk\n" # tag as Junk mail
macro pager S "<modify-labels-then-hide>-inbox -unread +junk\n" # tag as Junk mail
macro pager s "<modify-labels>-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 "<modify-labels>+archive -unread -inbox\n" # tag as Archived
macro index a "<modify-labels>-archive\n" # tag as Archived
macro pager A "<modify-labels>+archive -unread -inbox\n" # tag as Archived
macro pager a "<modify-labels>-archive\n" # tag as Archived
bind index U noop
bind index u noop
bind pager U noop
bind pager u noop
macro index U "<modify-labels>+unread\n"
macro index u "<modify-labels>-unread\n"
macro pager U "<modify-labels>+unread\n"
macro pager u "<modify-labels>-unread\n"
bind index t noop
bind pager t noop
macro index t "<modify-labels>" # set tags manual
macro pager t "<modify-labels>" # set tags manual
# top index bar in email view
set pager_index_lines=7
# top_index_bar toggle
macro pager ,@1 "<enter-command> set pager_index_lines=0; macro pager ] ,@2 'Toggle indexbar<Enter>"
macro pager ,@2 "<enter-command> set pager_index_lines=3; macro pager ] ,@3 'Toggle indexbar<Enter>"
macro pager ,@3 "<enter-command> set pager_index_lines=7; macro pager ] ,@1 'Toggle indexbar<Enter>"
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 <left> sidebar-prev # got to previous folder in sidebar
bind index <right> sidebar-next # got to next folder in sidebar
bind index <space> sidebar-open # open selected folder from sidebar
# sidebar toggle
#macro index,pager ,@) "<enter-command> set sidebar_visible=no; macro index,pager [ ,@( 'Toggle sidebar'<Enter>"
#macro index,pager ,@( "<enter-command> set sidebar_visible=yes; macro index,pager [ ,@) 'Toggle sidebar'<Enter>"
#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 ];
}