225 lines
7.2 KiB
Nix
225 lines
7.2 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
flake,
|
|
...
|
|
}:
|
|
with lib; let
|
|
psCfg = config.pub-solar;
|
|
xdg = config.home-manager.users."${psCfg.user.name}".xdg;
|
|
configHome = xdg.configHome;
|
|
cacheHome = xdg.cacheHome;
|
|
|
|
generateMailAccount = args@{ address, ... }: rec {
|
|
inherit address;
|
|
realName = psCfg.user.fullName;
|
|
signature = {
|
|
showSignature = "append";
|
|
text = builtins.readFile (./.config/neomutt + "/${builtins.replaceStrings ["@"] ["_"] address}.signature");
|
|
};
|
|
|
|
folders = {
|
|
inbox = "INBOX";
|
|
drafts = "Drafts";
|
|
sent = "Sent";
|
|
trash = "Trash";
|
|
};
|
|
|
|
gpg.key = psCfg.user.gpgKeyId;
|
|
|
|
userName = address;
|
|
passwordCommand = "secret-tool lookup email ${address}";
|
|
imap = {
|
|
host = mkIf (args ? "host") args.host;
|
|
port = 993;
|
|
};
|
|
smtp = {
|
|
host = mkIf (args ? "host") args.host;
|
|
port = 587;
|
|
tls.useStartTls = true;
|
|
};
|
|
|
|
offlineimap.enable = true;
|
|
imapnotify = {
|
|
enable = true;
|
|
boxes = [ "INBOX" ];
|
|
onNotify = "${pkgs.offlineimap}/bin/offlineimap -a ${address}";
|
|
onNotifyPost = "${pkgs.libnotify}/bin/notify-send '${address} has new mail'";
|
|
};
|
|
msmtp.enable = true;
|
|
neomutt = {
|
|
enable = true;
|
|
sendMailCommand = "msmtp -a ${address}";
|
|
extraConfig = ''
|
|
set pgp_default_key="${gpg.key}"
|
|
|
|
unmailboxes *
|
|
|
|
mailboxes +INBOX \
|
|
+Drafts \
|
|
+Sent \
|
|
+Archive \
|
|
+Trash
|
|
'';
|
|
};
|
|
} // (if args ? "config" then args.config else {});
|
|
in {
|
|
users.users."${psCfg.user.name}".packages = with pkgs; [
|
|
w3m
|
|
mailto-mutt
|
|
];
|
|
|
|
home-manager.users."${psCfg.user.name}" = rec {
|
|
xdg.configFile."neomutt/base16.muttrc".source = ./.config/neomutt/base16.muttrc;
|
|
xdg.configFile."neomutt/mailcap".source = ./.config/neomutt/mailcap;
|
|
xdg.configFile."urlscan/config.json".text = builtins.toJSON {
|
|
keys = {
|
|
"G" = "bottom";
|
|
"gg" = "top";
|
|
"k" = "down";
|
|
"i" = "up";
|
|
};
|
|
};
|
|
|
|
accounts.email = {
|
|
maildirBasePath = "/home/${psCfg.user.name}/Mail";
|
|
|
|
accounts = with flake.self.lib; lib.lists.foldr (item: set: (set // { "${item.address}" = generateMailAccount item; })) {} [
|
|
{
|
|
address = mkEmailAddress "hello" "benjaminbaedorf.eu";
|
|
host = "mail.hosting.de";
|
|
config.primary = true;
|
|
}
|
|
{
|
|
address = "mail@b12f.io";
|
|
host = "mail.b12f.io";
|
|
}
|
|
{
|
|
address = mkEmailAddress "benjamin.baedorf" "rwth-aachen.de";
|
|
host = "mail.rwth-aachen.de";
|
|
config.userName = mkEmailAddress "bb564306" "rwth-aachen.de";
|
|
}
|
|
{
|
|
address = mkEmailAddress "byb" "miom.space";
|
|
host = "mail.hosting.de";
|
|
}
|
|
{
|
|
address = mkEmailAddress "admins" "pub.solar";
|
|
host = "mail.greenbaum.zone";
|
|
}
|
|
{
|
|
address = mkEmailAddress "crew" "pub.solar";
|
|
host = "mail.greenbaum.zone";
|
|
}
|
|
# {
|
|
# address = mkEmailAddress "benjamin.yule.baedorf" "verkstedt.com";
|
|
# flavor = "gmail";
|
|
# config = {
|
|
# smtp.host = "smtp.gmail.com";
|
|
# imap.host = "imap.gmail.com";
|
|
# };
|
|
# }
|
|
{
|
|
address = mkEmailAddress "benjamin-yule.baedorf" "ext.ehealthexperts.de";
|
|
config = {
|
|
smtp.host = "smtp.mailbox.org";
|
|
imap.host = "imap.mailbox.org";
|
|
};
|
|
}
|
|
];
|
|
};
|
|
|
|
services.imapnotify.enable = true;
|
|
programs.offlineimap.enable = true;
|
|
programs.msmtp.enable = true;
|
|
programs.neomutt = {
|
|
enable = true;
|
|
binds = [
|
|
# Moving around
|
|
{ map = ["generic"]; key = "g"; action = "noop"; }
|
|
{ map = ["generic"]; key = "gg"; action = "first-entry"; }
|
|
{ map = ["generic" "index"]; key = "G"; action = "last-entry"; }
|
|
{ map = ["generic" "index"]; key = "i"; action = "previous-entry"; }
|
|
{ map = ["generic" "index"]; key = "k"; action = "next-entry"; }
|
|
{ map = ["pager" "index"]; key = "d"; action = "noop"; }
|
|
{ map = ["pager" "index"]; key = "dd"; action = "delete-message"; }
|
|
{ map = ["pager"]; key = "i"; action = "previous-line"; }
|
|
{ map = ["pager"]; key = "k"; action = "next-line"; }
|
|
{ map = ["pager"]; key = "I"; action = "previous-entry"; }
|
|
{ map = ["pager"]; key = "K"; action = "next-entry"; }
|
|
|
|
{ map = ["pager"]; key = "r"; action = "noop"; }
|
|
{ map = ["pager"]; key = "rr"; action = "reply"; }
|
|
{ map = ["pager"]; key = "ra"; action = "group-reply"; }
|
|
{ map = ["pager"]; key = "rn"; action = "group-chat-reply"; }
|
|
{ map = ["pager"]; key = "rl"; action = "list-reply"; }
|
|
|
|
# Threads
|
|
{ map = ["browser" "pager" "index"]; key = "N"; action = "search-opposite"; }
|
|
{ map = ["pager" "index"]; key = "dT"; action = "delete-thread"; }
|
|
{ map = ["pager" "index"]; key = "dt"; action = "delete-subthread"; }
|
|
{ map = ["pager" "index"]; key = "g"; action = "noop"; }
|
|
{ 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"; }
|
|
];
|
|
|
|
macros = [
|
|
# Enable URL opening
|
|
{
|
|
map = ["index" "pager"];
|
|
key = "\\Cb";
|
|
action = ''<pipe-message> ${pkgs.urlscan}/bin/urlscan<Enter>" "call urlscan to extract URLs out of a message'';
|
|
}
|
|
{
|
|
map = ["attach" "compose"];
|
|
key = "\\Cb";
|
|
action = ''<pipe-entry> ${pkgs.urlscan}/bin/urlscan<Enter>" "call urlscan to extract URLs out of a message'';
|
|
}
|
|
# Translate markdown to html
|
|
{
|
|
map = ["compose"];
|
|
key = "\\Cm";
|
|
action = ''F ${pkgs.pandoc}/bin/pandoc -s -f markdown -t html \ny^T^Utext/html; charset=utf-8\n" "Convert to HTML'';
|
|
}
|
|
# Save to ~/Downloads by default
|
|
{
|
|
map = ["attach"];
|
|
key = "S";
|
|
action = ''<save-entry><bol>~/Downloads/<eol>" "Save to Downloads'';
|
|
}
|
|
{
|
|
map = ["index"];
|
|
key = "\\Ca";
|
|
action = ''<tag-pattern>~N<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "Mark all as read'';
|
|
}
|
|
] ++ lib.lists.imap1 (i: address: {
|
|
map = ["index" "pager"];
|
|
key = "<F${builtins.toString i}>";
|
|
action = ''<sync-mailbox><enter-command>source ${configHome}/neomutt/${address}<enter><change-folder>!<enter>'';
|
|
}) (builtins.attrNames accounts.email.accounts);
|
|
|
|
# unmailboxes = true;
|
|
extraConfig = ''
|
|
source ${configHome}/neomutt/base16.muttrc
|
|
|
|
# HTML emails
|
|
auto_view text/html # view html automatically
|
|
alternative_order text/plain text/enriched text/html # save html for last
|
|
'';
|
|
|
|
settings = {
|
|
mark_old = "no";
|
|
sendmail_wait = "0";
|
|
crypt_verify_sig = "yes";
|
|
imap_check_subscribed = "yes";
|
|
date_format = ''"!%d.%m.%Y %H:%M"'';
|
|
index_format = ''"%4C %Z %D %4c %20.20L %s"'';
|
|
mailcap_path = "${configHome}/neomutt/mailcap";
|
|
};
|
|
};
|
|
};
|
|
}
|