From 819a23b52e8424dd2af5c47206cbc43bf63d8d78 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sun, 18 Dec 2022 12:07:29 +0100 Subject: [PATCH] Move mail configs --- home/{ => mail}/aerc/aerc.conf | 0 home/{ => mail}/aerc/binds.conf | 0 home/mail/default.nix | 264 ++++++++++++++++++++++++++++++ home/{ => mail}/mailcap | 0 home/{ => mail}/neomutt/neomuttrc | 0 5 files changed, 264 insertions(+) rename home/{ => mail}/aerc/aerc.conf (100%) rename home/{ => mail}/aerc/binds.conf (100%) create mode 100644 home/mail/default.nix rename home/{ => mail}/mailcap (100%) rename home/{ => mail}/neomutt/neomuttrc (100%) diff --git a/home/aerc/aerc.conf b/home/mail/aerc/aerc.conf similarity index 100% rename from home/aerc/aerc.conf rename to home/mail/aerc/aerc.conf diff --git a/home/aerc/binds.conf b/home/mail/aerc/binds.conf similarity index 100% rename from home/aerc/binds.conf rename to home/mail/aerc/binds.conf diff --git a/home/mail/default.nix b/home/mail/default.nix new file mode 100644 index 0000000..cf77fe9 --- /dev/null +++ b/home/mail/default.nix @@ -0,0 +1,264 @@ +{ pkgs, ... }: +let + mailBaseConfig = { + configName, + address, + userName ? address, + host, + displayName, + extraMailboxes ? [], + enableDefaultMailboxes ? true, + neomuttExtraConfig ? "", + } : let + defaultMailboxes = if enableDefaultMailboxes then + /* `tree ~/Maildir/vbrandl/ -l -d -I "Archive|cur|new|tmp|certs|.notmuch" -afin --noreport | awk '{if(NR>1)print}' | tr '\n' ' '` */ + [ "Drafts" "Junk" "Sent" "Trash" ] + else + []; + mailboxes = defaultMailboxes ++ extraMailboxes; + in { + address = address; + userName = userName; + realName = displayName; + imap.host = host; + smtp.host = host; + passwordCommand = "${pkgs.libsecret}/bin/secret-tool lookup email ${address}"; + signature = { + text = displayName; + showSignature = "append"; + }; + aerc = { + enable = true; + extraAccounts = { + pgp-opportunistic-encrypt = true; + pgp-autosign = true; + }; + }; + imapnotify = { + enable = true; + /* TODO: which boxes? */ + boxes = [ "Inbox" ]; + onNotify = "${pkgs.isync}/bin/mbsync ${configName} && ${pkgs.libnotify}/bin/notify-send -a mail '${configName}: new in %s'"; + /* onNotifyPost = { */ + /* mail = "${pkgs.libnotify}/bin/notify-send -a mail '${configName}: new in %s'"; */ + /* /1* update = "${pkgs.libnotify}/bin/notify-send -a mail '${configName}: update %s'"; *1/ */ + /* /1* expunge = "${pkgs.libnotify}/bin/notify-send -a mail '${configName}: expunge %s'"; *1/ */ + /* }; */ + }; + mbsync = { + enable = true; + /* sync changes to maildir in both directions */ + create = "both"; + expunge = "both"; + remove = "both"; + }; + msmtp.enable = true; + neomutt = { + enable = true; + extraMailboxes = mailboxes; + extraConfig = '' + # use encrypted headers + set crypt_protected_headers_write = yes + '' + neomuttExtraConfig; + }; + notmuch.enable = true; + }; +in { + home.packages = with pkgs; [ + libsecret + libnotify + urlview + ]; + home.file.mailcap = { + target = ".mailcap"; + source = ./mailcap; + }; + + programs.password-store.enable = true; + programs.aerc = { + enable = true; + extraConfig = builtins.readFile ./aerc/aerc.conf; + /* { */ + /* general = { */ + /* unsafe-accounts-conf = true; */ + /* }; */ + /* }; */ + extraBinds = builtins.readFile ./aerc/binds.conf; + }; + services.mbsync.enable = true; + programs.mbsync.enable = true; + services.imapnotify.enable = true; + programs.notmuch = { + enable = true; + hooks.preNew = "mbsync --all"; + }; + + programs.neomutt = { + enable = true; + sidebar.enable = true; + extraConfig = builtins.readFile ./neomutt/neomuttrc; + /* vimKeys = true; */ + macros = [ + { map = [ "pager" "index" ]; + key = "B"; + action = "|urlview\\n"; + } + ]; + binds = [ + /* sidebar */ + { map = [ "attach" "browser" "index" ]; + key = "J"; + action = "sidebar-next"; + } + { map = [ "attach" "browser" "index" ]; + key = "K"; + action = "sidebar-prev"; + } + { map = [ "attach" "browser" "index" ]; + key = "O"; + action = "sidebar-open"; + } + + /* moving around */ + { map = [ "attach" "browser" "index" ]; + key = "j"; + action = "next-entry"; + } + { map = [ "attach" "browser" "index" ]; + key = "k"; + action = "previous-entry"; + } + { map = [ "attach" "browser" "index" ]; + key = "g"; + action = "noop"; + } + { map = [ "attach" "browser" "index" ]; + key = "gg"; + action = "first-entry"; + } + { map = [ "attach" "browser" "index" ]; + key = "G"; + action = "last-entry"; + } + { map = [ "attach" "browser" "index" ]; + key = "n"; + action = "next-unread"; + } + { map = [ "pager" ]; + key = "g"; + action = "noop"; + } + { map = [ "pager" ]; + key = "gg"; + action = "top"; + } + { map = [ "pager" ]; + key = "G"; + action = "bottom"; + } + { map = [ "pager" ]; + key = "k"; + action = "previous-line"; + } + { map = [ "pager" ]; + key = "j"; + action = "next-line"; + } + + /* deletion */ + { map = [ "pager" "index" ]; + key = "d"; + action = "noop"; + } + { map = [ "pager" "index" ]; + key = "dd"; + action = "delete-message"; + } + /* TODO: mark as new? */ + { map = [ "browser" "pager" "index" ]; + key = "U"; + action = "toggle-new"; + } + { map = [ "browser" "pager" "index" ]; + key = "n"; + action = "search-next"; + } + { map = [ "browser" "pager" "index" ]; + key = "N"; + action = "search-opposite"; + } + + /* threads */ + { map = [ "pager" "index" ]; + key = "dT"; + action = "delete-thread"; + } + { map = [ "pager" "index" ]; + key = "dt"; + action = "delete-subthread"; + } + { map = [ "pager" "index" ]; + key = "gt"; + action = "next-thread"; + } + { map = [ "pager" "index" ]; + key = "gT"; + action = "previous-thread"; + } + { map = [ "index" ]; + key = "za"; + action = "collapse-thread"; + } + { map = [ "index" ]; + key = "zA"; + action = "collapse-all"; + } + ]; + }; + programs.msmtp.enable = true; + + accounts.email.accounts = let + aliases = "mail(\\+.*)?@vbrandl.net"; + in { + vbrandl = ( + mailBaseConfig { + configName = "vbrandl"; + address = "mail@vbrandl.net"; + host = "mail.vbrandl.net"; + displayName = "Valentin Brandl"; + extraMailboxes = [ "Archive" ]; + + /* #set use_from = yes */ + /* #set envelope_from = true */ + neomuttExtraConfig = '' + # TODO: reply with tagged mail + set reverse_name = yes + alternates '${aliases}' + ''; + }) // { + primary = true; + aliases = [ aliases ]; + gpg = { + encryptByDefault = true; + signByDefault = true; + key = "1FFE431282F4B8CC0A7579167FB009175885FC76"; + }; + }; + + riseup = ( + mailBaseConfig { + configName = "riseup"; + address = "vbrandl@riseup.net"; + host = "mail.riseup.net"; + displayName = "Valentin Brandl"; + extraMailboxes = [ "SKS-devel" ]; + }) // { + userName = "vbrandl"; + gpg = { + encryptByDefault = true; + signByDefault = true; + key = "1FFE431282F4B8CC0A7579167FB009175885FC76"; + }; + }; + }; +} diff --git a/home/mailcap b/home/mail/mailcap similarity index 100% rename from home/mailcap rename to home/mail/mailcap diff --git a/home/neomutt/neomuttrc b/home/mail/neomutt/neomuttrc similarity index 100% rename from home/neomutt/neomuttrc rename to home/mail/neomutt/neomuttrc