2022-06-16 21:19:04 +02:00
{ config , lib , pkgs , . . . }:
2022-12-10 16:03:16 +01:00
2022-06-16 19:00:34 +02:00
{
2022-06-16 21:19:04 +02:00
options = {
accounts . email . accounts = lib . mkOption {
type = lib . types . attrsOf ( lib . types . submodule {
2022-12-10 16:03:16 +01:00
options . aerc-sbruder . enable = lib . mkEnableOption " a e r c ( c u s t o m i m p l e m e n t a t i o n ) " ;
2022-06-16 21:19:04 +02:00
} ) ;
2022-06-16 19:00:34 +02:00
} ;
2022-06-16 21:19:04 +02:00
} ;
config = {
2022-12-10 16:03:16 +01:00
programs . aerc = {
enable = true ;
# incomplete support for all configuration options!
extraAccounts =
( lib . mapAttrs
( name : accountConfig : with accountConfig ; let
quoteMailAddress = lib . replaceChars [ " @ " " \\ " ] [ " % 4 0 " " % 5 C " ] ;
# home-manager has no way to set if an account requires AUTH LOGIN
# this emulats this by setting a list of known providers that do require it
requiresLogin = lib . elem
( lib . elemAt ( lib . strings . splitString " @ " address ) 1 )
[ " m a i l b o x . t u - d r e s d e n . d e " ] ;
in
{
source =
if notmuch . enable
then " n o t m u c h : / / ${ config . accounts . email . maildirBasePath } "
else " ` i m a p : / / ${ quoteMailAddress userName } @ ${ imap . host } ` " ;
source-cred-cmd = " ` ${ lib . concatStringsSep " " passwordCommand } ` " ;
# TODO: remove when copy-to is implemented in aerc for notmuch
outgoing =
if notmuch . enable
then " ${ ./msmtp-wrapper } ${ name } "
else " ` s m t p ${ lib . optionalString requiresLogin " + l o g i n " } : / / ${ quoteMailAddress userName } @ ${ smtp . host } ` " ;
outgoing-cred-cmd = " ` ${ lib . concatStringsSep " " passwordCommand } ` " ;
from = " ${ realName } < ${ address } > " ;
smtp-starttls = if smtp . tls . useStartTls then " y e s " else " n o " ;
copy-to = " S e n t " ;
signature-file = toString ( pkgs . writeText " s i g n a t u r e - ${ name } " signature . text ) ;
pgp-key-id = gpg . key ;
pgp-auto-sign = gpg . signByDefault ;
pgp-opportunistic-encrypt = gpg . encryptByDefault ;
} // ( lib . optionalAttrs notmuch . enable {
query-map = toString ( pkgs . writeText " a e r c - q u e r y - m a p " ''
Archive = not tag:inbox and not tag:sent
Git = tag:git
INBOX = tag:inbox
Newsletter = tag:newsletter
Sent = tag:sent
Spam = tag:spam
Trash = tag:deleted
eBay Kleinanzeigen = tag:kleinanzeigen
eBay = tag:ebay
'' ) ;
exclude-tags = lib . concatStringsSep " , " [
" a r c h i v e d "
" d e l e t e d "
" s p a m "
] ;
} ) )
( lib . filterAttrs
( _ : config : config . aerc-sbruder . enable )
config . accounts . email . accounts ) ) ;
extraConfig = {
2022-06-16 21:19:04 +02:00
general = {
pgp-provider = " g p g " ; # internal does not work
# Allow world-readable accounts.conf (passwords are not stored in it, so it is ok)
unsafe-accounts-conf = true ;
} ;
2022-06-16 19:00:34 +02:00
2022-06-16 21:19:04 +02:00
ui = {
2022-06-17 01:58:28 +02:00
index-format = " % - 1 7 . 1 7 D % - 2 0 . 2 0 n % Z % - 2 0 . 2 0 g % s " ;
2022-06-16 19:00:34 +02:00
2022-06-16 21:19:04 +02:00
# See https://godoc.org/time#Time.Format
timestamp-format = " 2 0 0 6 - 0 1 - 0 2 1 5 : 0 4 M S T " ;
this-day-time-format = " 1 5 : 0 4 " ;
this-week-time-format = " M o n d a y 1 5 : 0 4 " ;
this-year-time-format = " 0 2 J a n u a r y " ;
2022-06-16 19:00:34 +02:00
2022-06-16 21:19:04 +02:00
pinned-tab-marker = " 車 " ;
2022-06-16 19:00:34 +02:00
2022-06-16 21:19:04 +02:00
border-char-vertical = " │ " ;
border-char-horizontal = " ─ " ;
2022-06-16 19:00:34 +02:00
2022-06-16 21:19:04 +02:00
fuzzy-complete = true ;
2022-06-16 19:00:34 +02:00
2022-06-17 01:58:28 +02:00
#threading-enabled = true; # broken
2022-06-16 19:00:34 +02:00
2022-06-16 21:19:04 +02:00
new-message-bell = false ;
2022-06-16 19:00:34 +02:00
} ;
2022-06-16 21:19:04 +02:00
statusline = {
display-mode = " i c o n " ;
2022-06-16 19:00:34 +02:00
} ;
2022-06-16 21:19:04 +02:00
viewer = {
header-layout = lib . concatStringsSep " , " [
" F r o m | T o "
" C c | B c c "
" S u b j e c t "
" D a t e "
" R e p l y - T o "
" X - M a i l e r "
" U s e r - A g e n t "
] ;
2022-06-16 19:00:34 +02:00
} ;
compose = {
2022-06-16 21:19:04 +02:00
editor = " n v i m " ;
header-layout = lib . concatStringsSep " , " [
" T o | F r o m "
" S u b j e c t "
] ;
address-book-cmd = " k h a r d e m a i l - - p a r s a b l e - - r e m o v e - f i r s t - l i n e % s " ;
2022-06-16 19:00:34 +02:00
} ;
2022-06-16 21:19:04 +02:00
filters = {
2022-12-10 16:03:16 +01:00
" s u b j e c t , ~ ^ \\ [ P A T C H " = " a w k - f ${ pkgs . aerc } / s h a r e / a e r c / f i l t e r s / h l d i f f " ;
2022-06-16 21:19:04 +02:00
" t e x t / p l a i n " = " ${ ./colorize } " ; # taken from upstream and patched
" t e x t / h t m l " = " h t m l " ; # internal filter
2022-12-10 16:03:16 +01:00
" t e x t / c a l e n d a r " = " ${ pkgs . python3 . withPackages ( ps : with ps ; [ vobject ] ) } / b i n / p y t h o n ${ pkgs . aerc } / s h a r e / a e r c / f i l t e r s / s h o w - i c s - d e t a i l s . p y " ; # hacky fix for broken nix support
2022-06-16 19:00:34 +02:00
} ;
2022-06-16 21:19:04 +02:00
triggers = {
new-email = " e x e c n o t i f y - s e n d - i m a i l - u n r e a d - s y m b o l i c ' N e w e - m a i l f r o m % n ' ' % s ' " ;
2022-06-16 19:00:34 +02:00
} ;
2022-06-16 21:19:04 +02:00
templates = { } ;
} ;
2022-06-16 19:00:34 +02:00
2022-12-10 16:03:16 +01:00
extraBinds = {
global = {
2022-06-16 21:19:04 +02:00
# Binds are of the form <key sequence> = <command to run>
# To use '=' in a key sequence, substitute it with "Eq": "<Ctrl+Eq>"
# If you wish to bind #, you can wrap the key sequence in quotes: "#" = quit
2022-06-16 19:00:34 +02:00
" < C - p > " = " : p r e v - t a b < E n t e r > " ;
" < C - n > " = " : n e x t - t a b < E n t e r > " ;
2022-06-16 21:19:04 +02:00
" < C - t > " = " : t e r m < E n t e r > " ;
} ;
2022-12-10 16:03:16 +01:00
messages = {
" q " = " : q u i t < E n t e r > " ;
" < C - r > " = " : e x e c n o t m u c h n e w < E n t e r > " ;
" j " = " : n e x t < E n t e r > " ;
" < D o w n > " = " : n e x t < E n t e r > " ;
" < C - d > " = " : n e x t 5 0 % < E n t e r > " ;
" < C - f > " = " : n e x t 1 0 0 % < E n t e r > " ;
" < P g D n > " = " : n e x t 1 0 0 % < E n t e r > " ;
" k " = " : p r e v < E n t e r > " ;
" < U p > " = " : p r e v < E n t e r > " ;
" < C - u > " = " : p r e v 5 0 % < E n t e r > " ;
" < C - b > " = " : p r e v 1 0 0 % < E n t e r > " ;
" < P g U p > " = " : p r e v 1 0 0 % < E n t e r > " ;
" g " = " : s e l e c t 0 < E n t e r > " ;
" G " = " : s e l e c t - 1 < E n t e r > " ;
" J " = " : n e x t - f o l d e r < E n t e r > " ;
" K " = " : p r e v - f o l d e r < E n t e r > " ;
" H " = " : c o l l a p s e - f o l d e r < E n t e r > " ;
" L " = " : e x p a n d - f o l d e r < E n t e r > " ;
" v " = " : m a r k - t < E n t e r > " ;
" V " = " : m a r k - v < E n t e r > " ;
" T " = " : t o g g l e - t h r e a d s < E n t e r > " ;
" < E n t e r > " = " : v i e w < E n t e r > " ;
#"d" = ":prompt 'Really delete this message?' ':modify-labels +deleted'<Enter>"; # does not work
" D " = " : m o d i f y - l a b e l s + d e l e t e d - i n b o x < E n t e r > " ;
" A " = " : m o d i f y - l a b e l s - i n b o x < E n t e r > " ;
" m s " = " : m o d i f y - l a b e l s + s p a m - i n b o x < E n t e r > " ;
" m S " = " : m o d i f y - l a b e l s - s p a m + i n b o x < E n t e r > " ;
" m n " = " : m o d i f y - l a b e l s + n e w s l e t t e r < E n t e r > " ;
" m N " = " : m o d i f y - l a b e l s - n e w s l e t t e r < E n t e r > " ;
" C " = " : c o m p o s e < E n t e r > " ;
" r r " = " : r e p l y - a < E n t e r > " ;
" r q " = " : r e p l y - a q < E n t e r > " ;
" R r " = " : r e p l y < E n t e r > " ;
" R q " = " : r e p l y - q < E n t e r > " ;
" c " = " : c f < s p a c e > " ;
" $ " = " : t e r m < s p a c e > " ;
" ! " = " : t e r m < s p a c e > " ;
" | " = " : p i p e < s p a c e > " ;
" / " = " : s e a r c h < s p a c e > " ;
" \\ " = " : f i l t e r < s p a c e > " ;
" n " = " : n e x t - r e s u l t < E n t e r > " ;
" N " = " : p r e v - r e s u l t < E n t e r > " ;
" < E s c > " = " : c l e a r < E n t e r > " ;
} ;
view = {
" / " = " : t o g g l e - k e y - p a s s t h r o u g h < E n t e r > / " ;
" q " = " : c l o s e < E n t e r > " ;
" O " = " : o p e n < E n t e r > " ;
" S " = " : s a v e < s p a c e > " ;
" | " = " : p i p e < s p a c e > " ;
" D " = " : m o d i f y - l a b e l s + d e l e t e d - i n b o x < E n t e r > " ;
" A " = " : m o d i f y - l a b e l s - i n b o x < E n t e r > " ;
" f " = " : f o r w a r d < E n t e r > " ;
" r r " = " : r e p l y - a < E n t e r > " ;
" r q " = " : r e p l y - a q < E n t e r > " ;
" R r " = " : r e p l y < E n t e r > " ;
" R q " = " : r e p l y - q < E n t e r > " ;
" H " = " : t o g g l e - h e a d e r s < E n t e r > " ;
" < C - k > " = " : p r e v - p a r t < E n t e r > " ;
" < C - j > " = " : n e x t - p a r t < E n t e r > " ;
" J " = " : n e x t < E n t e r > " ;
" K " = " : p r e v < E n t e r > " ;
} ;
" v i e w : : p a s s t h r o u g h " = {
" $ n o i n h e r i t " = " t r u e " ;
" $ e x " = " < C - x > " ;
" < E s c > " = " : t o g g l e - k e y - p a s s t h r o u g h < E n t e r > " ;
} ;
# Keybindings used when the embedded terminal is not selected in the compose view"
compose = {
" $ e x " = " < C - x > " ;
" < C - k > " = " : p r e v - f i e l d < E n t e r > " ;
" < C - j > " = " : n e x t - f i e l d < E n t e r > " ;
" < t a b > " = " : n e x t - f i e l d < E n t e r > " ;
" < b a c k t a b > " = " : p r e v - f i e l d < E n t e r > " ;
} ;
# Keybindings used when the embedded terminal is selected in the compose view
" c o m p o s e : : e d i t o r " = {
" $ n o i n h e r i t " = " t r u e " ;
" $ e x " = " < C - x > " ;
" < C - k > " = " : p r e v - f i e l d < E n t e r > " ;
" < C - j > " = " : n e x t - f i e l d < E n t e r > " ;
" < C - p > " = " : p r e v - t a b < E n t e r > " ;
" < C - n > " = " : n e x t - t a b < E n t e r > " ;
} ;
# Keybindings used when reviewing a message to be sent
" c o m p o s e : : r e v i e w " = {
" y " = " : s e n d < E n t e r > " ;
" n " = " : a b o r t < E n t e r > " ;
" p " = " : p o s t p o n e < E n t e r > " ;
" q " = " : c h o o s e - o d d i s c a r d a b o r t - o p p o s t p o n e p o s t p o n e < E n t e r > " ;
" e " = " : e d i t < E n t e r > " ;
" a " = " : a t t a c h < s p a c e > " ;
" d " = " : d e t a c h < s p a c e > " ;
} ;
terminal = {
" $ n o i n h e r i t " = " t r u e " ;
" $ e x " = " < C - x > " ;
" < C - p > " = " : p r e v - t a b < E n t e r > " ;
" < C - n > " = " : n e x t - t a b < E n t e r > " ;
2022-06-16 19:00:34 +02:00
} ;
} ;
2022-12-10 16:03:16 +01:00
stylesets = {
default = {
" * . s e l e c t e d . r e v e r s e " = true ;
2022-06-16 19:00:34 +02:00
2022-12-10 16:03:16 +01:00
" t i t l e . r e v e r s e " = true ;
" h e a d e r . b o l d " = true ;
2022-06-16 19:00:34 +02:00
2022-12-10 16:03:16 +01:00
" * e r r o r . b o l d " = true ;
" e r r o r . f g " = 1 ;
" w a r n i n g . f g " = 3 ;
" s u c c e s s . f g " = 2 ;
2022-06-16 19:00:34 +02:00
2022-12-10 16:03:16 +01:00
" s t a t u s l i n e _ d e f a u l t . b g " = 0 ;
" s t a t u s l i n e _ e r r o r . f g " = 1 ;
" s t a t u s l i n e _ e r r o r . r e v e r s e " = true ;
" s t a t u s l i n e _ s u c c e s s . f g " = 2 ;
" s t a t u s l i n e _ s u c c e s s . r e v e r s e " = true ;
2022-06-16 19:00:34 +02:00
2022-12-10 16:03:16 +01:00
" m s g l i s t _ u n r e a d . b o l d " = true ;
" m s g l i s t _ d e l e t e d . f g " = 10 ;
2022-06-16 19:00:34 +02:00
2022-12-10 16:03:16 +01:00
" t a b . b g " = 11 ;
" t a b . s e l e c t e d . r e v e r s e " = false ;
" t a b . s e l e c t e d . b g " = 12 ;
" t a b . f g " = 0 ;
2022-06-16 19:00:34 +02:00
2022-12-10 16:03:16 +01:00
" c o m p l e t i o n _ d e f a u l t . b g " = 0 ;
} ;
} ;
2022-06-16 21:19:04 +02:00
} ;
2022-12-10 16:03:16 +01:00
#quoteMailAddress = lib.replaceChars [ "@" "\\" ] [ "%40" "%5C" ];
## home-manager has no way to set if an account requires AUTH LOGIN
## this emulats this by setting a list of known providers that do require it
#requiresLogin = lib.elem
# (lib.elemAt (lib.strings.splitString "@" address) 1)
# [ "mailbox.tu-dresden.de" ];
2022-06-16 19:00:34 +02:00
} ;
}