From 98d41aa9374b033f194f940ba3983babc29e5ef8 Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Wed, 7 Nov 2018 12:15:57 -0800 Subject: Configure email --- emacs-packages.nix | 1 + home.nix | 97 ++++++++++++++++++++++++++++------------------- install.sh | 7 ++++ msmtprc | 19 +++++----- mutt/notmuch-hook.sh | 35 ----------------- notmuch | 104 --------------------------------------------------- notmuch-hook.sh | 33 ++++++++++++++++ packages.nix | 2 - 8 files changed, 110 insertions(+), 188 deletions(-) delete mode 100755 mutt/notmuch-hook.sh delete mode 100644 notmuch create mode 100755 notmuch-hook.sh diff --git a/emacs-packages.nix b/emacs-packages.nix index 76c90a2..ae881a0 100644 --- a/emacs-packages.nix +++ b/emacs-packages.nix @@ -46,6 +46,7 @@ org-plus-contrib org-pomodoro org-trello pass +pinentry projectile restclient s diff --git a/home.nix b/home.nix index 0c4acb2..6a7c5c6 100644 --- a/home.nix +++ b/home.nix @@ -5,35 +5,38 @@ let homedir = builtins.getEnv "HOME"; in { - # Waiting for the accounts feature to land in the 18.03 release branch... - # - #accounts = { - # email = { - # maildirBasePath = "$HOME/Mail"; - # accounts = { - # "ben@bsima.me" = { - # primary = true; - # realName = "Ben Sima"; - # address = "ben@bsima.me"; - # folders = { - # inbox = "INBOX"; - # }; - # imap = { - # host = "mail.bsima.me"; - # port = 993; - # }; - # smtp = { - # host = "mail.bsima.me"; - # port = 587; - # }; - # userName = "ben@bsima.me"; - # mbsync.enable = true; - # notmuch.enable = true; - # passwordCommand = "pass bnet/helium/mail/ben"; - # }; - # }; - # }; - #}; + accounts = { + email = { + maildirBasePath = "${homedir}/Mail"; + accounts = { + "ben@bsima.me" = { + primary = true; + realName = "Ben Sima"; + address = "ben@bsima.me"; + folders = { + inbox = "INBOX"; + }; + imap = { + host = "mail.bsima.me"; + port = 993; + }; + smtp = { + host = "mail.bsima.me"; + port = 587; + }; + userName = "ben@bsima.me"; + mbsync = { + enable = true; + create = "both"; + expunge = "none"; + }; + notmuch.enable = true; + msmtp.enable = false; + passwordCommand = "pass bnet/helium/mail/ben"; + }; + }; + }; + }; home = { packages = import ./packages.nix { inherit pkgs; }; sessionVariables = { @@ -52,14 +55,6 @@ in source = ./mailcap; target = ".mailcap"; }; - msmtp = { - source = ./msmtprc; - target = ".msmtprc"; - }; - notmuch = { - source = ./notmuch; - target = ".notmuch-config"; - }; tmux = { source = ./tmux; target = ".tmux.conf"; @@ -149,6 +144,10 @@ in enable = true; defaultCacheTtl = 600; enableSshSupport = true; + extraConfig = '' + allow-emacs-pinentry + pinentry-program /home/ben/.nix-profile/bin/pinentry-tty + ''; }; }; @@ -271,6 +270,28 @@ in firefox = { enable = true; }; - }; + notmuch = { + enable = true; + new.tags = [ "unread" "inbox" ]; + hooks = { + preNew = "mbsync --all"; + postNew = builtins.readFile ./notmuch-hook.sh; + }; + extraConfig = { + search = { + exclude_tags = "deleted;spam;"; + }; + }; + }; + + mbsync = { + enable = true; + }; + + msmtp = { + enable = false; + extraConfig = builtins.readFile ./msmtprc; + }; + }; } diff --git a/install.sh b/install.sh index fb37c4a..a9bf4d8 100755 --- a/install.sh +++ b/install.sh @@ -11,3 +11,10 @@ nix-shell $HM_PATH -A install mkdir -p ~/.config [[ -L ~/config ]] && ln -s ~/config/home.nix ~/.config/nixpkgs/home.nix + +# The notmuch config location is by default ~/.notmuch-config, but home-manager +# puts it at ~/.config/notmuch/notmuchrc (which makes sense) and then sets +# NOTMUCH_CONFIG. However, if a program for some reason doesn't read +# NOTMUCH_CONFIG (emacs), then it won't find the right config file, so I +# override with a symlink. +[[ -L ~/.notmuch-config ]] && ln -s ~/.config/notmuch/notmuchrc ~/.notmuch-config diff --git a/msmtprc b/msmtprc index d5078e3..76f8683 100644 --- a/msmtprc +++ b/msmtprc @@ -1,15 +1,16 @@ -account bnet +account ben@bsima.me +auth on +from ben@bsima.me +host mail.bsima.me +user ben@bsima.me +passwordeval pass bnet/helium/mail/ben port 587 -tls on +tls on # Get the fingerprint with # $ msmtp --serverinfo --tls --tls-certcheck=off --host=mail.bsima.me tls_fingerprint 4A:61:06:B6:EE:ED:87:82:82:73:4A:09:10:DE:A4:A4:E8:42:EC:F9:A6:C7:A5:51:6E:AB:09:A0:BF:49:26:33 +#tls_starttls off +#tls_trust_file /etc/ssl/certs/ca-certificates.crt -host mail.bsima.me -from ben@bsima.me -auth on -user ben@bsima.me -passwordeval pass bnet/helium/mail/ben - -account default : bnet +account default : ben@bsima.me diff --git a/mutt/notmuch-hook.sh b/mutt/notmuch-hook.sh deleted file mode 100755 index 15b9362..0000000 --- a/mutt/notmuch-hook.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env sh - -notmuch new - -# retag all "new" messages "inbox" and "unread" -notmuch tag +inbox +unread -new -- tag:new - -# tag all messages from "me" as sent -notmuch tag +sent -inbox -unread -- from:ben@bsima.me - -# tag TODOs from myself, always mark as unread so I'm forced to process them -notmuch tag +todo -inbox +unread -- subject:TODO and from:ben@bsima.me and to:ben@bsima.me - -# tag some newsletters, but don't show them in inbox -notmuch tag +newsletters -inbox -- \ - from:the-morning-paper@onelanday.co.uk or \ - from:newsletter@fightaging.org or \ - subject:'The Reading List Email*' or \ - from:info@haskellweekly.news or \ - from:kale@hackernewsletter.com - -# tag logwatch emails & remove from inbox -notmuch tag +logwatch -new -inbox -- subject:'Logwatch*' - -# tag job-related emails -notmuch tag +jobs -inbox -- \ - from:alist.co or \ - from:angel.co or \ - from:stackoverflow.com or \ - from:stackoverflow.email or \ - from:cdmtechnology.com or \ - subject:job - -# tag github emails -notmuch tag +github -inbox -- from:github.com diff --git a/notmuch b/notmuch deleted file mode 100644 index a26c613..0000000 --- a/notmuch +++ /dev/null @@ -1,104 +0,0 @@ -# .notmuch-config - Configuration file for the notmuch mail system -# -# For more information about notmuch, see https://notmuchmail.org - -# Database configuration -# -# The only value supported here is 'path' which should be the top-level -# directory where your mail currently exists and to where mail will be -# delivered in the future. Files should be individual email messages. -# Notmuch will store its database within a sub-directory of the path -# configured here named ".notmuch". -# - -[database] -path=/home/ben/Mail - -# User configuration -# -# Here is where you can let notmuch know how you would like to be -# addressed. Valid settings are -# -# name Your full name. -# primary_email Your primary email address. -# other_email A list (separated by ';') of other email addresses -# at which you receive email. -# -# Notmuch will use the various email addresses configured here when -# formatting replies. It will avoid including your own addresses in the -# recipient list of replies, and will set the From address based on the -# address to which the original email was addressed. -# - -[user] -name=Ben Sima -primary_email=ben@bsima.me - -# Configuration for "notmuch new" -# -# The following options are supported here: -# -# tags A list (separated by ';') of the tags that will be -# added to all messages incorporated by "notmuch new". -# -# ignore A list (separated by ';') of file and directory names -# that will not be searched for messages by "notmuch new". -# -# NOTE: *Every* file/directory that goes by one of those -# names will be ignored, independent of its depth/location -# in the mail store. -# -other_email=bsima@me.com;bensima@gmail.com;bsima@icloud.com; - -[new] -tags=new -ignore= - -# Search configuration -# -# The following option is supported here: -# -# exclude_tags -# A ;-separated list of tags that will be excluded from -# search results by default. Using an excluded tag in a -# query will override that exclusion. -# - -[search] -exclude_tags=deleted;spam; - -# Maildir compatibility configuration -# -# The following option is supported here: -# -# synchronize_flags Valid values are true and false. -# -# If true, then the following maildir flags (in message filenames) -# will be synchronized with the corresponding notmuch tags: -# -# Flag Tag -# ---- ------- -# D draft -# F flagged -# P passed -# R replied -# S unread (added when 'S' flag is not present) -# -# The "notmuch new" command will notice flag changes in filenames -# and update tags, while the "notmuch tag" and "notmuch restore" -# commands will notice tag changes and update flags in filenames -# - -[maildir] -synchronize_flags=true - -# Cryptography related configuration -# -# The following option is supported here: -# -# gpg_path -# binary name or full path to invoke gpg. -# - -[crypto] -gpg_path=gpg diff --git a/notmuch-hook.sh b/notmuch-hook.sh new file mode 100755 index 0000000..a55a2e1 --- /dev/null +++ b/notmuch-hook.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env sh + +# tag all messages from "me" as sent +notmuch tag +sent -inbox -unread -- from:ben@bsima.me + +# tag TODOs from myself, always mark as unread so I'm forced to process them +notmuch tag +todo -inbox +unread -- subject:TODO and from:ben@bsima.me and to:ben@bsima.me + +# tag some newsletters, but don't show them in inbox +notmuch tag +newsletters -inbox -- \ + from:the-morning-paper@onelanday.co.uk or \ + from:newsletter@fightaging.org or \ + subject:'The Reading List Email*' or \ + from:info@haskellweekly.news or \ + from:kale@hackernewsletter.com + +# tag logwatch emails & remove from inbox +notmuch tag +logwatch -new -inbox -- subject:'Logwatch*' + +# tag job-related emails +notmuch tag +jobs -inbox -- \ + from:alist.co or \ + from:angel.co or \ + from:stackoverflow.com or \ + from:stackoverflow.email or \ + from:cdmtechnology.com or \ + subject:job + +# tag github emails +notmuch tag +github -inbox -- from:github.com + +# haskell-cafe +notmuch tag +haskell -- to:haskell-cafe@haskell.org diff --git a/packages.nix b/packages.nix index cceda60..caaddf2 100644 --- a/packages.nix +++ b/packages.nix @@ -34,8 +34,6 @@ pkgs.ncdu pkgs.neomutt # pkgs.networkmanager_vpnc #pkgs.nix-prefetch-scripts -#pkgs.notmuch -#pkgs.offlineimap pkgs.pass pkgs.pandoc # pkgs.pasystray -- cgit v1.2.3