2025-01-03 13:36:02 +01:00
|
|
|
# TODO: Clean this mess
|
2024-04-11 20:15:47 +02:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
2025-01-03 13:36:02 +01:00
|
|
|
extraInfo,
|
2024-04-11 20:15:47 +02:00
|
|
|
...
|
|
|
|
}:
|
2023-10-22 17:12:42 +02:00
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
mailAccountModule = types.submodule {
|
2025-01-03 13:36:02 +01:00
|
|
|
options = {
|
|
|
|
isPrimary = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
};
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2025-01-03 13:36:02 +01:00
|
|
|
mailAddress = mkOption { type = types.str; };
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2025-01-03 13:36:02 +01:00
|
|
|
mailPasswdEval = mkOption { type = types.str; };
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2025-01-03 13:36:02 +01:00
|
|
|
imapHost = mkOption { type = types.str; };
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2025-01-03 13:36:02 +01:00
|
|
|
smtpHost = mkOption { type = types.str; };
|
|
|
|
};
|
2023-10-22 17:12:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
defaultExtraMailboxes = [
|
|
|
|
"Archive"
|
|
|
|
"Junk"
|
|
|
|
"Drafts"
|
|
|
|
"Sent"
|
|
|
|
"Trash"
|
|
|
|
];
|
|
|
|
|
|
|
|
signature = {
|
|
|
|
text = ''
|
|
|
|
Victor Mignot
|
|
|
|
'';
|
|
|
|
showSignature = "append";
|
|
|
|
};
|
|
|
|
|
2025-01-03 13:36:02 +01:00
|
|
|
mailDefaults = {
|
|
|
|
"perso" = {
|
|
|
|
isPrimary = true;
|
|
|
|
mailAddress = extraInfo.mail.personal.address;
|
|
|
|
mailPasswdEval = mkDefault "";
|
|
|
|
imapHost = extraInfo.mail.personal.imapServer;
|
|
|
|
smtpHost = extraInfo.mail.personal.smtpServer;
|
|
|
|
};
|
|
|
|
|
|
|
|
"public" = {
|
|
|
|
mailAddress = extraInfo.mail.public.address;
|
|
|
|
mailPasswdEval = mkDefault "";
|
|
|
|
imapHost = extraInfo.mail.public.imapServer;
|
|
|
|
smtpHost = extraInfo.mail.public.smtpServer;
|
|
|
|
};
|
|
|
|
};
|
2023-10-22 17:12:42 +02:00
|
|
|
in
|
|
|
|
{
|
2025-01-03 13:36:02 +01:00
|
|
|
options.my.communications.mail = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
accounts = mkOption {
|
|
|
|
type = types.attrsOf mailAccountModule;
|
|
|
|
};
|
2023-10-22 17:12:42 +02:00
|
|
|
};
|
|
|
|
|
2025-01-03 13:36:02 +01:00
|
|
|
config = mkIf config.my.communications.mail.enable {
|
|
|
|
my.communications.mail.accounts = mailDefaults;
|
2023-10-22 17:12:42 +02:00
|
|
|
|
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;
|
2025-01-03 13:36:02 +01:00
|
|
|
smtp.host = value.smtpHost;
|
2024-04-11 20:15:47 +02:00
|
|
|
passwordCommand = value.mailPasswdEval;
|
|
|
|
inherit signature;
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2024-04-11 20:15:47 +02:00
|
|
|
mbsync = {
|
|
|
|
enable = true;
|
|
|
|
create = "both";
|
|
|
|
expunge = "both";
|
|
|
|
patterns = [ "*" ];
|
|
|
|
subFolders = "Verbatim";
|
|
|
|
};
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2024-04-11 20:15:47 +02:00
|
|
|
msmtp.enable = true;
|
2023-10-22 17:12:42 +02:00
|
|
|
|
2024-04-11 20:15:47 +02:00
|
|
|
neomutt = {
|
|
|
|
enable = true;
|
|
|
|
mailboxName = "${name}/Inbox";
|
|
|
|
extraMailboxes = map (mb: {
|
|
|
|
mailbox = mb;
|
|
|
|
name = "${name}/${mb}";
|
|
|
|
}) defaultExtraMailboxes;
|
|
|
|
};
|
2024-08-01 21:40:51 +02:00
|
|
|
}) config.my.communications.mail.accounts;
|
2023-10-22 17:12:42 +02:00
|
|
|
|
|
|
|
services.mbsync.enable = true;
|
|
|
|
programs.mbsync.enable = true;
|
2025-01-03 13:36:02 +01:00
|
|
|
programs.msmtp.enable = true;
|
2023-10-22 17:12:42 +02:00
|
|
|
|
|
|
|
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.*"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|