nixos-configuration/home/mail/default.nix

310 lines
7.3 KiB
Nix
Raw Normal View History

2022-12-18 12:07:29 +01:00
{ 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;
2023-05-20 13:34:11 +02:00
passwordCommand = "${pkgs.libsecret}/bin/secret-tool lookup email ${address}";
2023-05-12 18:23:11 +02:00
signature = {
text = displayName;
showSignature = "append";
};
2022-12-18 12:07:29 +01:00
aerc = {
enable = true;
extraAccounts = {
pgp-opportunistic-encrypt = true;
pgp-autosign = true;
};
};
imapnotify = {
enable = true;
/* TODO: which boxes? */
boxes = [ "Inbox" ];
2023-10-29 09:25:22 +01:00
onNotify = "${pkgs.isync}/bin/mbsync ${configName}";
2023-05-13 12:51:24 +02:00
onNotifyPost = "${pkgs.libnotify}/bin/notify-send -a mail '${configName}: new in %s'";
2022-12-18 12:07:29 +01:00
};
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;
};
2023-05-12 18:23:53 +02:00
notmuch = {
enable = true;
neomutt.virtualMailboxes = [
{
name = "My INBOX";
query = "tag:inbox";
}
{
name = "Unread";
query = "tag:unread";
}
];
};
2022-12-18 12:07:29 +01:00
};
in {
home.packages = with pkgs; [
libsecret
libnotify
2024-06-15 16:02:25 +02:00
urlscan
2022-12-18 12:07:29 +01:00
];
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;
package = pkgs.writeShellScriptBin "mbsync" ''
${pkgs.isync}/bin/mbsync $@
${pkgs.notmuch}/bin/notmuch new
'';
};
2022-12-18 12:07:29 +01:00
services.imapnotify.enable = true;
programs.notmuch = {
enable = true;
};
programs.neomutt = {
enable = true;
sidebar.enable = true;
extraConfig = builtins.readFile ./neomutt/neomuttrc;
/* vimKeys = true; */
macros = [
{ map = [ "pager" "index" ];
key = "B";
2024-06-15 16:02:25 +02:00
action = "|urlscan\\n";
2022-12-18 12:07:29 +01:00
}
2023-10-29 09:25:22 +01:00
/*{ map = [ "pager" "index" ];
key = "dd";
action = ":set delete = yes\\n<clear-flag>N<delete-message>";
}*/
2022-12-18 12:07:29 +01:00
];
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
2024-07-19 00:57:43 +02:00
aliases = ".*@vbrandl.net";
2022-12-18 12:07:29 +01:00
in {
vbrandl = (
mailBaseConfig {
configName = "vbrandl";
address = "mail@vbrandl.net";
host = "mail.vbrandl.net";
displayName = "Valentin Brandl";
2023-05-12 18:24:08 +02:00
extraMailboxes = [
"Archive"
"Banking"
"Conversation"
"Covid"
"Dev"
"Memberships"
2023-05-13 12:54:20 +02:00
"Newsletter"
2023-05-12 18:24:08 +02:00
"Orders"
"Rent"
"Social"
"Support"
"Travel"
"Uni"
"Work"
];
2022-12-18 12:07:29 +01:00
/* #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";
2023-05-12 18:24:08 +02:00
extraMailboxes = [
"Archive"
"Banking"
"Contracts"
"Conversation"
"Dev"
"Mailinglists"
"Newsletter"
"Orders"
"Social"
"Support"
"Travel"
"Uni"
];
2022-12-18 12:07:29 +01:00
}) // {
userName = "vbrandl";
gpg = {
encryptByDefault = true;
signByDefault = true;
key = "1FFE431282F4B8CC0A7579167FB009175885FC76";
};
};
};
}