248 lines
7.5 KiB
Nix
248 lines
7.5 KiB
Nix
{ config, lib, pkgs, hostName, ... }:
|
|
|
|
{
|
|
programs = {
|
|
mbsync = {
|
|
enable = true;
|
|
groups.inboxes = {
|
|
proton = [ "INBOX" ];
|
|
icloud = [ "INBOX" ];
|
|
};
|
|
};
|
|
msmtp.enable = true;
|
|
mu.enable = true;
|
|
};
|
|
services = {
|
|
mbsync = {
|
|
enable = true;
|
|
frequency = "*:0/15";
|
|
};
|
|
imapnotify.enable = true;
|
|
};
|
|
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}";
|
|
imapnotify = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
boxes = [ "INBOX" ];
|
|
onNotify = "${pkgs.isync}/bin/mbsync --pull proton:INBOX";
|
|
onNotifyPost =
|
|
"${pkgs.libnotify}/bin/notify-send 'Proton: New mail arrived'";
|
|
extraConfig = {
|
|
wait = 300;
|
|
tls = false;
|
|
tlsOptions.rejectUnauthorized = false;
|
|
};
|
|
};
|
|
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;
|
|
};
|
|
icloud = let accountEnabled = true;
|
|
in rec {
|
|
inherit realName;
|
|
primary = lib.mkDefault false; # TEMP until proton is fixed
|
|
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}";
|
|
imapnotify = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
boxes = [ "INBOX" ];
|
|
onNotify = "${pkgs.isync}/bin/mbsync --pull icloud:INBOX";
|
|
onNotifyPost =
|
|
"${pkgs.libnotify}/bin/notify-send 'Proton: New mail arrived'";
|
|
extraConfig.wait = 300;
|
|
};
|
|
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;
|
|
};
|
|
ukaea = let
|
|
host = "127.0.0.1";
|
|
tls.enable = false;
|
|
accountEnabled = true;
|
|
in rec {
|
|
inherit realName;
|
|
primary = lib.mkDefault false;
|
|
maildir.path = "UKAEA";
|
|
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}";
|
|
imapnotify = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
boxes = [ "INBOX" ];
|
|
onNotify = "${pkgs.isync}/bin/mbsync --pull ukaea:INBOX";
|
|
onNotifyPost =
|
|
"${pkgs.libnotify}/bin/notify-send 'Proton: New mail arrived'";
|
|
extraConfig = {
|
|
wait = 300;
|
|
tls = false;
|
|
tlsOptions.rejectUnauthorized = false;
|
|
};
|
|
};
|
|
mbsync = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
create = "both";
|
|
expunge = "both";
|
|
remove = "both";
|
|
patterns =
|
|
[ "*" "!Junk" "!Snoozed" "!Sync Issues" "!Unsent Messages" ];
|
|
subFolders = "Verbatim";
|
|
extraConfig.account.AuthMechs = "LOGIN";
|
|
};
|
|
msmtp.extraConfig = {
|
|
enable = lib.mkDefault accountEnabled;
|
|
tls = "off";
|
|
auth = "login";
|
|
};
|
|
mu.enable = lib.mkDefault accountEnabled;
|
|
};
|
|
};
|
|
};
|
|
systemd.user.services = {
|
|
imapnotify-proton.Unit = {
|
|
Wants = [ "protonmail-bridge.service" ];
|
|
After = [ "protonmail-bridge.service" ];
|
|
};
|
|
imapnotify-ukaea.Unit = {
|
|
Wants = [ "davmail.service" ];
|
|
After = [ "davmail.service" ];
|
|
};
|
|
protonmail-bridge =
|
|
lib.mkIf config.accounts.email.accounts.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";
|
|
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 config.accounts.email.accounts.ukaea.mbsync.enable {
|
|
Unit = {
|
|
Description = "Podman container-davmail.service";
|
|
Documentation = [ "man:podman-generate-systemd(1)" ];
|
|
Wants = [ "network-online.target" ];
|
|
After = [ "network-online.target" ];
|
|
RequiresMountsFor = "%t/containers";
|
|
};
|
|
Service = {
|
|
Environment = "PODMAN_SYSTEMD_UNIT=%n";
|
|
Restart = "always";
|
|
TimeoutStopSec = 70;
|
|
ExecStart = ''
|
|
${pkgs.podman}/bin/podman run \
|
|
--cidfile=%t/%n.ctr-id \
|
|
--cgroups=no-conmon \
|
|
--rm \
|
|
--sdnotify=conmon \
|
|
--replace \
|
|
-d \
|
|
--name=davmail \
|
|
-p 127.0.0.1:1026:1025 \
|
|
-p 127.0.0.1:1144:1143 \
|
|
-p 127.0.0.1:1080:1080 connectical/davmail
|
|
'';
|
|
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" ];
|
|
};
|
|
};
|
|
}
|