nixos-config/modules/workstation/home-manager/mail.nix

119 lines
3.5 KiB
Nix
Raw Normal View History

2024-04-11 20:15:47 +02:00
{
lib,
pkgs,
config,
...
}:
with lib;
let
mailAccountModule = types.submodule {
isPrimary = mkOption {
type = types.bool;
default = false;
};
2024-04-11 20:15:47 +02:00
mailAddress = mkOption { type = types.str; };
2024-04-11 20:15:47 +02:00
mailPasswdEval = mkOption { type = types.str; };
2024-04-11 20:15:47 +02:00
imapHost = mkOption { type = types.str; };
2024-04-11 20:15:47 +02:00
smtpHost = mkOption { type = types.str; };
};
defaultExtraMailboxes = [
"Archive"
"Receipts"
"Junk"
"Drafts"
"Sent"
"Trash"
];
signature = {
text = ''
Victor Mignot
'';
showSignature = "append";
};
hasNoAddress = config.communication.mailAccounts == null;
in
{
options.communication.mailAccounts = mkOption {
type = types.nullOr (types.attrsOf mailAccountModule);
default = null;
};
config = mkIf (!hasNoAddress) {
2024-04-11 20:15:47 +02:00
accounts.email.accounts = builtins.mapAttrs (name: value: {
primary = value.isPrimary;
address = value.mailAddress;
userName = value.mailAddress;
realName = "Victor Mignot";
imap.host = value.imapHost;
smtpHost = value.smtpHost;
passwordCommand = value.mailPasswdEval;
inherit signature;
2024-04-11 20:15:47 +02:00
mbsync = {
enable = true;
create = "both";
expunge = "both";
patterns = [ "*" ];
subFolders = "Verbatim";
};
2024-04-11 20:15:47 +02:00
msmtp.enable = true;
2024-04-11 20:15:47 +02:00
neomutt = {
enable = true;
mailboxName = "${name}/Inbox";
extraMailboxes = map (mb: {
mailbox = mb;
name = "${name}/${mb}";
}) defaultExtraMailboxes;
};
}) config.communication.mailAccounts;
services.mbsync.enable = true;
programs.mbsync.enable = true;
accounts.email.maildirBasePath = "Mail";
programs.neomutt = {
enable = true;
sidebar.enable = true;
checkStatsInterval = 30;
sort = "reverse-date";
extraConfig = ''
set edit_headers = yes
set use_from = yes
set send_charset = "utf-8"
color body brightwhite default ^[[:space:]].*
color body yellow default ^(diff).*
color body brightwhite default ^(\s).*
color body cyan default ^(Signed-off-by).*
color body cyan default ^(Docker-DCO-1.1-Signed-off-by).*
color body brightwhite default ^(Cc)
color body yellow default "^diff \-.*"
color body brightwhite default "^index [a-f0-9].*"
color body brightblue default "^---$"
color body white default "^\-\-\- .*"
color body white default "^[\+]{3} .*"
color body green default "^[\+][^\+]+.*"
color body red default "^\-[^\-]+.*"
color body brightblue default "^@@ .*"
color body green default "LGTM"
color body brightmagenta default "-- Commit Summary --"
color body brightmagenta default "-- File Changes --"
color body brightmagenta default "-- Patch Links --"
color body green default "^Merged #.*"
color body red default "^Closed #.*"
color body brightblue default "^Reply to this email.*"
'';
};
};
}