2022-04-10 11:54:58 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
2022-05-09 01:23:14 +02:00
|
|
|
mapAttrs
|
2022-04-09 21:35:15 +02:00
|
|
|
mkEnableOption
|
|
|
|
mkIf
|
2022-04-10 11:54:58 +02:00
|
|
|
;
|
2022-05-09 01:51:11 +02:00
|
|
|
inherit
|
|
|
|
(builtins)
|
|
|
|
typeOf
|
|
|
|
;
|
2022-04-09 21:35:15 +02:00
|
|
|
|
|
|
|
myName = "Antoine Martin";
|
|
|
|
email_perso = "antoine@alarsyo.net";
|
|
|
|
email_lrde = "amartin@lrde.epita.fr";
|
2022-05-09 01:23:14 +02:00
|
|
|
email_prologin = "antoine.martin@prologin.org";
|
2022-04-09 21:35:15 +02:00
|
|
|
|
|
|
|
cfg = config.my.home.mail;
|
2022-05-09 01:23:14 +02:00
|
|
|
|
2022-05-09 01:51:11 +02:00
|
|
|
make_mbsync_channel = patterns:
|
|
|
|
(
|
|
|
|
if (typeOf patterns) == "list"
|
|
|
|
then {
|
|
|
|
inherit patterns;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
farPattern = patterns.far;
|
|
|
|
nearPattern = patterns.near;
|
|
|
|
}
|
|
|
|
)
|
|
|
|
// {
|
|
|
|
extraConfig = {
|
|
|
|
Create = "Both";
|
|
|
|
Expunge = "Both";
|
|
|
|
Remove = "None";
|
|
|
|
SyncState = "*";
|
|
|
|
};
|
2022-05-09 01:23:14 +02:00
|
|
|
};
|
|
|
|
make_mbsync_channels = mapAttrs (_: value: make_mbsync_channel value);
|
|
|
|
|
|
|
|
gmail_far_near_patterns = {
|
|
|
|
sent = {
|
|
|
|
far = "[Gmail]/Sent Mail";
|
|
|
|
near = "Sent";
|
|
|
|
};
|
|
|
|
drafts = {
|
|
|
|
far = "[Gmail]/Drafts";
|
|
|
|
near = "Drafts";
|
|
|
|
};
|
|
|
|
junk = {
|
|
|
|
far = "[Gmail]/Spam";
|
|
|
|
near = "Junk";
|
|
|
|
};
|
|
|
|
trash = {
|
|
|
|
far = "[Gmail]/Trash";
|
|
|
|
near = "Trash";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
gmail_mbsync_channels = make_mbsync_channels gmail_far_near_patterns;
|
2022-04-10 11:54:58 +02:00
|
|
|
in {
|
2022-04-09 21:35:15 +02:00
|
|
|
options.my.home.mail = {
|
|
|
|
# I *could* read email in a terminal emacs client on a server, but in
|
|
|
|
# practice I don't think it'll happen very often, so let's enable this only
|
|
|
|
# when I'm on a machine with a Xorg server.
|
2022-04-10 11:54:58 +02:00
|
|
|
enable = (mkEnableOption "email configuration") // {default = config.my.home.x.enable;};
|
2022-04-09 21:35:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
accounts.email = {
|
|
|
|
maildirBasePath = "${config.home.homeDirectory}/.mail";
|
|
|
|
accounts = {
|
|
|
|
alarsyo = {
|
|
|
|
address = email_perso;
|
|
|
|
userName = email_perso;
|
|
|
|
realName = myName;
|
|
|
|
aliases = [
|
|
|
|
"alarsyo@alarsyo.net"
|
|
|
|
"antoine@amartin.email"
|
|
|
|
];
|
|
|
|
flavor = "plain"; # default setting
|
|
|
|
passwordCommand = "${pkgs.rbw}/bin/rbw get webmail.migadu.com ${email_perso}";
|
|
|
|
primary = true;
|
|
|
|
mbsync = {
|
|
|
|
enable = true;
|
|
|
|
create = "both";
|
|
|
|
expunge = "both";
|
2022-05-02 17:04:34 +02:00
|
|
|
groups = {
|
2022-05-09 01:51:11 +02:00
|
|
|
alarsyo-main.channels = make_mbsync_channels {
|
|
|
|
main = ["INBOX" "Sent" "Drafts" "Junk" "Trash"];
|
2022-05-02 17:04:34 +02:00
|
|
|
};
|
2022-05-09 01:51:11 +02:00
|
|
|
alarsyo-full.channels = make_mbsync_channels {
|
|
|
|
full = ["*" "!INBOX" "!Sent" "!Drafts" "!Junk" "!Trash"];
|
2022-05-02 17:04:34 +02:00
|
|
|
};
|
|
|
|
};
|
2022-04-09 21:35:15 +02:00
|
|
|
};
|
|
|
|
msmtp.enable = true;
|
|
|
|
mu.enable = true;
|
|
|
|
imap = {
|
|
|
|
host = "imap.migadu.com";
|
|
|
|
port = 993;
|
|
|
|
tls.enable = true;
|
|
|
|
};
|
|
|
|
smtp = {
|
|
|
|
host = "smtp.migadu.com";
|
|
|
|
port = 465;
|
|
|
|
tls.enable = true;
|
|
|
|
};
|
|
|
|
};
|
2022-04-10 00:59:05 +02:00
|
|
|
lrde = {
|
|
|
|
address = email_lrde;
|
|
|
|
userName = "amartin";
|
|
|
|
realName = myName;
|
|
|
|
flavor = "plain"; # default setting
|
|
|
|
passwordCommand = "${pkgs.rbw}/bin/rbw get lrde.epita.fr amartin";
|
|
|
|
mbsync = {
|
|
|
|
enable = true;
|
|
|
|
create = "both";
|
|
|
|
expunge = "both";
|
2022-05-02 17:05:26 +02:00
|
|
|
patterns = ["*" "!Archives*"];
|
2022-04-10 00:59:05 +02:00
|
|
|
extraConfig.account = {
|
|
|
|
# otherwise mbsync tries GSSAPI, but I don't have Kerberos setup
|
|
|
|
# on this machine
|
|
|
|
AuthMechs = "LOGIN";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
msmtp.enable = true;
|
|
|
|
mu.enable = true;
|
|
|
|
imap = {
|
|
|
|
host = "imap.lrde.epita.fr";
|
|
|
|
port = 993;
|
|
|
|
tls.enable = true;
|
|
|
|
};
|
|
|
|
smtp = {
|
|
|
|
host = "smtp.lrde.epita.fr";
|
|
|
|
port = 465;
|
|
|
|
tls.enable = true;
|
|
|
|
};
|
|
|
|
};
|
2022-05-09 01:23:14 +02:00
|
|
|
prologin = {
|
|
|
|
address = email_prologin;
|
|
|
|
userName = email_prologin;
|
|
|
|
realName = myName;
|
|
|
|
aliases = [
|
|
|
|
"alarsyo@prologin.org"
|
|
|
|
];
|
|
|
|
flavor = "plain"; # default setting
|
|
|
|
passwordCommand = "${pkgs.rbw}/bin/rbw get google.com ${email_prologin}-mailpass";
|
|
|
|
primary = false;
|
|
|
|
mbsync = {
|
|
|
|
enable = true;
|
|
|
|
create = "both";
|
|
|
|
expunge = "both";
|
|
|
|
groups = {
|
|
|
|
prologin-main.channels =
|
2022-05-09 01:51:11 +02:00
|
|
|
(make_mbsync_channels {
|
|
|
|
main = ["INBOX" "membres@"];
|
|
|
|
})
|
2022-05-09 01:23:14 +02:00
|
|
|
// gmail_mbsync_channels;
|
2022-05-09 01:51:11 +02:00
|
|
|
prologin-info.channels = make_mbsync_channels {
|
|
|
|
info = ["info@" "info@gcc"];
|
2022-05-09 01:23:14 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
msmtp.enable = true;
|
|
|
|
mu.enable = true;
|
|
|
|
imap = {
|
|
|
|
host = "imap.gmail.com";
|
|
|
|
port = 993;
|
|
|
|
tls.enable = true;
|
|
|
|
};
|
|
|
|
smtp = {
|
|
|
|
host = "smtp.gmail.com";
|
|
|
|
port = 465;
|
|
|
|
tls.enable = true;
|
|
|
|
};
|
|
|
|
};
|
2022-04-09 21:35:15 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
programs.mbsync.enable = true;
|
2022-04-10 00:58:56 +02:00
|
|
|
programs.msmtp.enable = true;
|
2022-04-09 21:35:15 +02:00
|
|
|
programs.mu.enable = true;
|
|
|
|
};
|
|
|
|
}
|