Evie Litherland-Smith
192872bac0
emacs/mu4e can call mbsync more frequently when being used, systemd service is just to keep emails roughly in sync if mu4e is not open
239 lines
8.3 KiB
Nix
239 lines
8.3 KiB
Nix
{ config, lib, pkgs, ... }: {
|
|
home.packages = with pkgs; [ davmail ];
|
|
accounts.email = {
|
|
maildirBasePath = "Mail";
|
|
accounts = let realName = "Evie Litherland-Smith";
|
|
in {
|
|
proton = let
|
|
host = "127.0.0.1";
|
|
tls.enable = false;
|
|
accountEnabled = true;
|
|
in rec {
|
|
inherit realName;
|
|
primary = lib.mkDefault true;
|
|
maildir.path = "Proton";
|
|
imap = {
|
|
inherit host tls;
|
|
port = 1143;
|
|
};
|
|
smtp = {
|
|
inherit host tls;
|
|
port = 1025;
|
|
};
|
|
address = "e.litherlandsmith@proton.me";
|
|
aliases = [ "evie@xenia.me.uk" "evie@litherlandsmith.slmail.me" ];
|
|
userName = address;
|
|
passwordCommand =
|
|
"${pkgs.libsecret}/bin/secret-tool lookup email ${userName}";
|
|
mbsync = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
create = "both";
|
|
expunge = "both";
|
|
remove = "both";
|
|
patterns = [ "*" "!All Mail" "!Spam" "!Labels*" "!Starred" ];
|
|
subFolders = "Verbatim";
|
|
extraConfig.account.AuthMechs = "LOGIN";
|
|
};
|
|
msmtp = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
extraConfig = {
|
|
tls = "off";
|
|
auth = "login";
|
|
};
|
|
};
|
|
mu.enable = lib.mkDefault accountEnabled;
|
|
neomutt.enable = lib.mkDefault accountEnabled;
|
|
};
|
|
icloud = let accountEnabled = true;
|
|
in rec {
|
|
inherit realName;
|
|
primary = lib.mkDefault false;
|
|
maildir.path = "iCloud";
|
|
imap.host = "imap.mail.me.com";
|
|
smtp.host = "smtp.mail.me.com";
|
|
address = "e.litherlandsmith@icloud.com";
|
|
userName = address;
|
|
passwordCommand =
|
|
"${pkgs.libsecret}/bin/secret-tool lookup email ${userName}";
|
|
mbsync = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
create = "both";
|
|
expunge = "both";
|
|
remove = "both";
|
|
patterns = [ "*" "!Junk" ];
|
|
subFolders = "Verbatim";
|
|
};
|
|
msmtp.enable = lib.mkDefault accountEnabled;
|
|
mu.enable = lib.mkDefault accountEnabled;
|
|
neomutt.enable = lib.mkDefault accountEnabled;
|
|
};
|
|
outlook = let
|
|
host = "127.0.0.1";
|
|
tls.enable = false;
|
|
accountEnabled = true;
|
|
in rec {
|
|
inherit realName;
|
|
primary = lib.mkDefault false;
|
|
maildir.path = "Outlook";
|
|
imap = {
|
|
inherit host tls;
|
|
port = 1144;
|
|
};
|
|
smtp = {
|
|
inherit host tls;
|
|
port = 1026;
|
|
};
|
|
address = "evie.litherland-smith@ukaea.uk";
|
|
aliases = [ "elitherl@jet.uk" ];
|
|
userName = address;
|
|
passwordCommand =
|
|
"${pkgs.libsecret}/bin/secret-tool lookup email ${userName}";
|
|
mbsync = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
create = "both";
|
|
expunge = "both";
|
|
remove = "both";
|
|
patterns = [
|
|
"*"
|
|
"!Conversation History"
|
|
"!Junk"
|
|
"!Snoozed"
|
|
"!Social Activity Notifications"
|
|
"!Sync Issues"
|
|
"!Unsent Messages"
|
|
];
|
|
subFolders = "Verbatim";
|
|
extraConfig.account.AuthMechs = "LOGIN";
|
|
};
|
|
msmtp = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
extraConfig = {
|
|
tls = "off";
|
|
auth = "login";
|
|
};
|
|
};
|
|
mu.enable = lib.mkDefault accountEnabled;
|
|
neomutt.enable = lib.mkDefault accountEnabled;
|
|
};
|
|
};
|
|
};
|
|
programs = {
|
|
mu.enable = true;
|
|
msmtp.enable = true;
|
|
mbsync = {
|
|
enable = true;
|
|
groups.inboxes = {
|
|
proton = [ "INBOX" ];
|
|
icloud = [ "INBOX" ];
|
|
outlook = [ "INBOX" ];
|
|
};
|
|
};
|
|
neomutt = {
|
|
enable = true;
|
|
checkStatsInterval = 60;
|
|
sidebar.enable = true;
|
|
extraConfig = ''
|
|
color normal default default # Text is "Text"
|
|
color index color2 default ~N # New Messages are Green
|
|
color index color1 default ~F # Flagged messages are Red
|
|
color index color13 default ~T # Tagged Messages are Red
|
|
color index color1 default ~D # Messages to delete are Red
|
|
color attachment color5 default # Attachments are Pink
|
|
color signature color8 default # Signatures are Surface 2
|
|
color search color4 default # Highlighted results are Blue
|
|
|
|
color indicator default color8 # currently highlighted message Surface 2=Background Text=Foreground
|
|
color error color1 default # error messages are Red
|
|
color status color15 default # status line "Subtext 0"
|
|
color tree color15 default # thread tree arrows Subtext 0
|
|
color tilde color15 default # blank line padding Subtext 0
|
|
|
|
color hdrdefault color13 default # default headers Pink
|
|
color header color13 default "^From:"
|
|
color header color13 default "^Subject:"
|
|
|
|
color quoted color15 default # Subtext 0
|
|
color quoted1 color7 default # Subtext 1
|
|
color quoted2 color8 default # Surface 2
|
|
color quoted3 color0 default # Surface 1
|
|
color quoted4 color0 default
|
|
color quoted5 color0 default
|
|
|
|
color body color2 default [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+ # email addresses Green
|
|
color body color2 default (https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+ # URLs Green
|
|
color body color4 default (^|[[:space:]])\\*[^[:space:]]+\\*([[:space:]]|$) # *bold* text Blue
|
|
color body color4 default (^|[[:space:]])_[^[:space:]]+_([[:space:]]|$) # _underlined_ text Blue
|
|
color body color4 default (^|[[:space:]])/[^[:space:]]+/([[:space:]]|$) # /italic/ text Blue
|
|
|
|
color sidebar_flagged color1 default # Mailboxes with flagged mails are Red
|
|
color sidebar_new color10 default # Mailboxes with new mail are Green
|
|
'';
|
|
};
|
|
};
|
|
services.mbsync = {
|
|
enable = true;
|
|
frequency = "*:0/15"; # Every 15 minutes
|
|
};
|
|
systemd.user.services = let emailAccounts = config.accounts.email.accounts;
|
|
in {
|
|
protonmail-bridge = lib.mkIf emailAccounts.proton.mbsync.enable {
|
|
Unit = {
|
|
Description = "Podman container-protonmail-bridge.service";
|
|
Documentation = [ "man:podman-generate-systemd(1)" ];
|
|
Wants = [ "network-online.target" ];
|
|
After = [ "network-online.target" ];
|
|
RequiresMountsFor = "%t/containers";
|
|
};
|
|
Service = {
|
|
Environment =
|
|
[ "PODMAN_SYSTEMD_UNIT=%n" "PATH=/run/wrappers/bin/:$PATH" ];
|
|
Restart = "always";
|
|
TimeoutStopSec = 70;
|
|
ExecStart = ''
|
|
${pkgs.podman}/bin/podman run \
|
|
--cidfile=%t/%n.ctr-id \
|
|
--cgroups=no-conmon \
|
|
--rm \
|
|
--sdnotify=conmon \
|
|
--replace \
|
|
-d \
|
|
--name=protonmail-bridge \
|
|
-v protonmail:/root \
|
|
-p 127.0.0.1:1025:25/tcp \
|
|
-p 127.0.0.1:1143:143/tcp shenxn/protonmail-bridge'';
|
|
ExecStop = ''
|
|
${pkgs.podman}/bin/podman stop \
|
|
--ignore -t 10 \
|
|
--cidfile=%t/%n.ctr-id'';
|
|
ExecStopPost = ''
|
|
${pkgs.podman}/bin/podman rm \
|
|
-f \
|
|
--ignore -t 10 \
|
|
--cidfile=%t/%n.ctr-id'';
|
|
Type = "notify";
|
|
NotifyAccess = "all";
|
|
};
|
|
Install.WantedBy = [ "default.target" ];
|
|
};
|
|
davmail = lib.mkIf emailAccounts.outlook.mbsync.enable {
|
|
Unit = {
|
|
Description = "Davmail server";
|
|
Wants = [ "network-online.target" ];
|
|
After = [ "network-online.target" ];
|
|
};
|
|
Service = {
|
|
Environment = [ "PATH=/run/current-system/sw/bin/:$PATH" ];
|
|
Restart = "always";
|
|
ExecStartPre = with config.home; ''
|
|
/bin/sh -c "if [ ! -f ${homeDirectory}/.davmail.properties ]; then cp ${
|
|
./.davmail.properties
|
|
} ${homeDirectory}/.davmail.properties; fi; chmod 644 ${homeDirectory}/.davmail.properties"
|
|
'';
|
|
ExecStart =
|
|
"${pkgs.davmail}/bin/davmail -notray ${config.home.homeDirectory}/.davmail.properties";
|
|
};
|
|
Install.WantedBy = [ "default.target" ];
|
|
};
|
|
};
|
|
}
|