stockholm/lass/2configs/mail.nix

217 lines
7.5 KiB
Nix
Raw Normal View History

2018-01-23 22:21:47 +00:00
with import <stockholm/lib>;
2016-04-19 11:23:38 +00:00
{ pkgs, ... }:
let
msmtprc = pkgs.writeText "msmtprc" ''
defaults
logfile ~/.msmtp.log
account prism
host prism.r
2018-03-13 21:39:38 +00:00
account c-base
from lassulus@c-base.org
host c-mail.c-base.org
port 465
tls on
tls_starttls off
tls_fingerprint 8C:10:A6:AB:1F:82:C4:8F:B1:B4:22:D5:8B:8B:49:9B:59:0B:22:A4
auth on
user lassulus
passwordeval pass show c-base/pass
2016-04-19 11:23:38 +00:00
account default: prism
'';
2016-06-22 17:12:34 +00:00
msmtp = pkgs.writeBashBin "msmtp" ''
${pkgs.coreutils}/bin/tee >(${pkgs.notmuch}/bin/notmuch insert +sent) | \
2016-11-24 23:22:34 +00:00
${pkgs.msmtp}/bin/msmtp -C ${msmtprc} "$@"
2016-04-19 11:23:38 +00:00
'';
2017-08-01 11:47:10 +00:00
mailcap = pkgs.writeText "mailcap" ''
text/html; ${pkgs.elinks}/bin/elinks -dump ; copiousoutput;
'';
2018-01-23 22:41:16 +00:00
mailboxes = {
2018-02-13 16:28:25 +00:00
c-base = [ "to:c-base.org" ];
2018-03-03 17:36:58 +00:00
coins = [
"to:btce@lassul.us"
"to:coinbase@lassul.us"
"to:polo@lassul.us"
"to:bitwala@lassul.us"
"to:payeer@lassul.us"
"to:gatehub@lassul.us"
"to:bitfinex@lassul.us"
"to:binance@lassul.us"
"to:bitcoin.de@lassul.us"
"to:robinhood@lassul.us"
];
2018-02-25 22:33:15 +00:00
dezentrale = [ "to:dezentrale.space" ];
2018-03-03 17:36:58 +00:00
dhl = [ "to:dhl@lassul.us" ];
2018-03-13 21:40:46 +00:00
eloop = [ "to:eloop.org" ];
2018-03-03 17:36:58 +00:00
github = [ "to:github@lassul.us" ];
gmail = [ "to:gmail@lassul.us" "to:lassulus@gmail.com" "lassulus@googlemail.com" ];
kaosstuff = [ "to:gearbest@lassul.us" "to:banggood@lassul.us" "to:tomtop@lassul.us" ];
2018-03-13 21:40:46 +00:00
lugs = [ "to:lugs@lug-s.org" ];
2018-02-13 16:28:25 +00:00
nix-devel = [ "to:nix-devel@googlegroups.com" ];
2018-02-25 22:33:15 +00:00
patreon = [ "to:patreon@lassul.us" ];
2018-03-03 17:36:58 +00:00
paypal = [ "to:paypal@lassul.us" ];
ptl = [ "to:ptl@posttenebraslab.ch" ];
retiolum = [ "to:lass@mors.r" ];
security = [ "to:seclists.org" "to:bugtraq" "to:securityfocus@lassul.us" ];
2018-02-13 16:28:25 +00:00
shack = [ "to:shackspace.de" ];
2018-03-03 17:36:58 +00:00
steam = [ "to:steam@lassul.us" ];
tinc = [ "to:tinc@tinc-vpn.org" "to:tinc-devel@tinc-vpn.org" ];
2018-02-25 22:33:15 +00:00
wireguard = [ "to:wireguard@lists.zx2c4" ];
2018-03-03 17:36:58 +00:00
zzz = [ "to:pizza@lassul.us" "to:spam@krebsco.de" ];
2018-01-23 22:41:16 +00:00
};
2018-01-23 22:21:47 +00:00
2018-03-03 17:36:58 +00:00
tag-new-mails = pkgs.writeDashBin "nm-tag-init" ''
2018-02-25 22:32:59 +00:00
${pkgs.notmuch}/bin/notmuch new
${concatMapStringsSep "\n" (i: ''${pkgs.notmuch}/bin/notmuch tag -inbox +${i.name} -- tag:inbox ${concatMapStringsSep " or " (f: "${f}") i.value}'') (mapAttrsToList nameValuePair mailboxes)}
'';
2018-03-03 17:36:58 +00:00
tag-old-mails = pkgs.writeDashBin "nm-tag-old" ''
${concatMapStringsSep "\n" (i: ''${pkgs.notmuch}/bin/notmuch tag -inbox -archive +${i.name} -- ${concatMapStringsSep " or " (f: "${f}") i.value}'') (mapAttrsToList nameValuePair mailboxes)}
'';
2016-04-19 11:23:38 +00:00
muttrc = pkgs.writeText "muttrc" ''
2016-04-19 14:57:56 +00:00
# gpg
2018-03-29 14:39:08 +00:00
source ${pkgs.neomutt}/share/doc/neomutt/samples/gpg.rc
2016-04-19 14:57:56 +00:00
set pgp_use_gpg_agent = yes
2018-03-15 18:33:43 +00:00
set pgp_sign_as = 0xDC2A43EF4F11E854B44D599A89E82952976A7E4D
2016-04-19 14:57:56 +00:00
set crypt_autosign = yes
set crypt_replyencrypt = yes
2016-05-19 22:16:46 +00:00
set crypt_verify_sig = yes
set pgp_verify_command = "gpg --no-verbose --batch --output - --verify %s %f"
macro index \Cv \
"<enter-command> set my_crypt_verify_sig=\$crypt_verify_sig<enter> \
<enter-command> set crypt_verify_sig=yes<enter> \
<display-message><enter-command> set crypt_verify_sig=\$my_crypt_verify_sig<enter>" \
'Verify PGP signature and open the message'
macro pager \Cv \
"<exit><enter-command> set my_crypt_verify_sig=\$crypt_verify_sig<enter> \
<enter-command> set crypt_verify_sig=yes<enter> \
<display-message><enter-command> set crypt_verify_sig=\$my_crypt_verify_sig<enter>" \
'Verify PGP signature'
2017-08-01 11:47:10 +00:00
# read html mails
auto_view text/html
set mailcap_path = ${mailcap}
2016-04-19 14:57:56 +00:00
2016-04-19 11:23:38 +00:00
# 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
2017-07-10 22:07:22 +00:00
set sendmail="${msmtp}/bin/msmtp" # enables parsing of outgoing mail
2016-08-24 06:40:01 +00:00
set from="lassulus@lassul.us"
2017-07-10 22:07:22 +00:00
alternates ^.*@lassul\.us$ ^.*@.*\.r$
2016-04-19 11:23:38 +00:00
set use_from=yes
set envelope_from=yes
2017-07-10 22:07:22 +00:00
set reverse_name
2016-04-19 11:23:38 +00:00
2017-07-04 14:40:07 +00:00
set sort=threads
2017-07-10 22:08:05 +00:00
set index_format="${pkgs.writeDash "mutt-index" ''
# http://www.mutt.org/doc/manual/#formatstrings
2017-07-12 18:10:17 +00:00
recipent="$(echo $1 | sed 's/[^,]*<\([^>]*\)[^,]*/ \1/g')"
2017-07-10 22:08:05 +00:00
# output to mutt
# V
2017-08-01 12:15:45 +00:00
echo "%4C %Z %?GI?%GI& ? %[%y-%m-%d] %-20.20a %?M?(%3M)& ? %s %> $recipent %?g?%g?%"
2017-07-10 22:08:05 +00:00
# args to mutt-index dash script
# V
''} %r |"
2016-04-19 11:23:38 +00:00
2018-02-25 22:32:59 +00:00
virtual-mailboxes "INBOX" "notmuch://?query=tag:inbox"
2018-02-13 16:28:25 +00:00
virtual-mailboxes "Unread" "notmuch://?query=tag:unread"
2018-02-25 22:32:59 +00:00
${concatMapStringsSep "\n" (i: ''${" "}virtual-mailboxes "${i.name}" "notmuch://?query=tag:${i.name}"'') (mapAttrsToList nameValuePair mailboxes)}
2018-02-13 16:28:25 +00:00
virtual-mailboxes "TODO" "notmuch://?query=tag:TODO"
virtual-mailboxes "Starred" "notmuch://?query=tag:*"
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=*"
2016-04-19 11:23:38 +00:00
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
#killed
bind index d noop
bind pager d noop
2017-03-14 10:17:57 +00:00
bind index S noop
bind index s noop
2016-04-19 11:23:38 +00:00
bind pager S noop
2017-03-14 10:17:57 +00:00
bind pager s noop
2016-04-19 11:23:38 +00:00
macro index S "<modify-labels-then-hide>-inbox -unread +junk\n" # tag as Junk mail
2017-03-14 10:17:57 +00:00
macro index s "<modify-labels>-junk\n" # tag as Junk mail
2016-04-19 11:23:38 +00:00
macro pager S "<modify-labels-then-hide>-inbox -unread +junk\n" # tag as Junk mail
2017-03-14 10:17:57 +00:00
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
2016-04-19 11:23:38 +00:00
bind index t noop
bind pager t noop
2017-08-25 21:47:25 +00:00
macro index t "<modify-labels>" # tag as Archived
2016-04-19 11:23:38 +00:00
2017-08-01 16:06:13 +00:00
# top index bar in email view
set pager_index_lines=7
2016-04-19 11:23:38 +00:00
# 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 ,@) "<enter-command> set sidebar_visible=no; macro index ~ ,@( 'Toggle sidebar'<Enter>"
macro index ,@( "<enter-command> set sidebar_visible=yes; macro index ~ ,@) 'Toggle sidebar'<Enter>"
macro index ~ ,@( 'Toggle sidebar' # toggle the sidebar
'';
2017-06-20 17:30:14 +00:00
mutt = pkgs.symlinkJoin {
name = "mutt";
paths = [
(pkgs.writeDashBin "mutt" ''
2018-03-29 14:39:08 +00:00
exec ${pkgs.neomutt}/bin/neomutt -F ${muttrc} $@
2017-06-20 17:30:14 +00:00
'')
pkgs.neomutt
2017-06-20 17:30:14 +00:00
];
};
2016-04-19 11:23:38 +00:00
in {
environment.systemPackages = [
msmtp
mutt
pkgs.much
2018-03-03 17:36:58 +00:00
tag-new-mails
tag-old-mails
2016-04-19 11:23:38 +00:00
];
2018-04-28 09:29:46 +00:00
nixpkgs.config.packageOverrides = opkgs: {
notmuch = (opkgs.notmuch.overrideAttrs (o: { doCheck = false; }));
};
2016-04-19 11:23:38 +00:00
}