2023-09-29 09:28:11 +01:00
|
|
|
{ config, lib, pkgs, hostName, ... }:
|
2023-09-02 08:41:07 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
programs = {
|
2023-09-25 17:59:40 +01:00
|
|
|
mbsync = {
|
|
|
|
enable = true;
|
|
|
|
groups.inboxes = {
|
|
|
|
proton = [ "INBOX" ];
|
|
|
|
icloud = [ "INBOX" ];
|
|
|
|
};
|
|
|
|
};
|
2023-09-14 11:56:26 +01:00
|
|
|
msmtp.enable = true;
|
2023-09-29 08:31:39 +01:00
|
|
|
mu.enable = true;
|
2023-09-14 17:09:21 +01:00
|
|
|
};
|
2023-10-01 09:17:45 +01:00
|
|
|
services = {
|
|
|
|
mbsync = {
|
|
|
|
enable = true;
|
|
|
|
frequency = "*:0/15";
|
|
|
|
};
|
|
|
|
imapnotify.enable = true;
|
|
|
|
};
|
2023-09-25 17:59:40 +01:00
|
|
|
accounts.email = {
|
|
|
|
maildirBasePath = ".mail";
|
|
|
|
accounts = let realName = "Evie Litherland-Smith";
|
|
|
|
in {
|
|
|
|
proton = let
|
|
|
|
host = "127.0.0.1";
|
|
|
|
tls.enable = false;
|
2023-10-01 12:04:09 +01:00
|
|
|
accountEnabled = true;
|
2023-09-25 17:59:40 +01:00
|
|
|
in rec {
|
|
|
|
inherit realName;
|
2023-10-01 11:40:47 +01:00
|
|
|
primary = lib.mkDefault true;
|
2023-09-25 17:59:40 +01:00
|
|
|
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;
|
2023-09-30 09:27:43 +01:00
|
|
|
passwordCommand =
|
|
|
|
"${pkgs.libsecret}/bin/secret-tool lookup email ${userName}";
|
2023-09-29 09:28:11 +01:00
|
|
|
imapnotify = {
|
2023-10-01 12:04:09 +01:00
|
|
|
enable = lib.mkDefault accountEnabled;
|
2023-09-29 09:28:11 +01:00
|
|
|
boxes = [ "INBOX" ];
|
2023-10-04 16:39:34 +01:00
|
|
|
onNotify = "${pkgs.isync}/bin/mbsync --pull-new proton:INBOX";
|
2023-09-29 14:55:18 +01:00
|
|
|
onNotifyPost =
|
|
|
|
"${pkgs.libnotify}/bin/notify-send 'Proton: New mail arrived'";
|
2023-09-29 09:28:11 +01:00
|
|
|
extraConfig = {
|
2023-09-30 10:11:58 +01:00
|
|
|
wait = 300;
|
2023-09-29 09:28:11 +01:00
|
|
|
tls = false;
|
|
|
|
tlsOptions.rejectUnauthorized = false;
|
|
|
|
};
|
|
|
|
};
|
2023-09-25 17:59:40 +01:00
|
|
|
mbsync = {
|
2023-10-01 12:04:09 +01:00
|
|
|
enable = lib.mkDefault accountEnabled;
|
2023-09-25 17:59:40 +01:00
|
|
|
create = "both";
|
|
|
|
expunge = "both";
|
|
|
|
remove = "both";
|
2023-09-26 10:49:13 +01:00
|
|
|
patterns = [ "*" "!All Mail" "!Spam" "!Labels*" "!Starred" ];
|
2023-09-25 17:59:40 +01:00
|
|
|
subFolders = "Verbatim";
|
|
|
|
extraConfig.account.AuthMechs = "LOGIN";
|
|
|
|
};
|
|
|
|
msmtp = {
|
2023-10-01 12:04:09 +01:00
|
|
|
enable = lib.mkDefault accountEnabled;
|
2023-09-25 17:59:40 +01:00
|
|
|
extraConfig = {
|
|
|
|
tls = "off";
|
|
|
|
auth = "login";
|
|
|
|
};
|
|
|
|
};
|
2023-10-01 12:04:09 +01:00
|
|
|
mu.enable = lib.mkDefault accountEnabled;
|
2023-09-25 17:59:40 +01:00
|
|
|
};
|
2023-10-01 12:04:09 +01:00
|
|
|
icloud = let accountEnabled = true;
|
|
|
|
in rec {
|
2023-09-25 17:59:40 +01:00
|
|
|
inherit realName;
|
2023-10-01 11:40:47 +01:00
|
|
|
primary = lib.mkDefault false; # TEMP until proton is fixed
|
2023-09-25 17:59:40 +01:00
|
|
|
maildir.path = "iCloud";
|
|
|
|
imap.host = "imap.mail.me.com";
|
|
|
|
smtp.host = "smtp.mail.me.com";
|
|
|
|
address = "e.litherlandsmith@icloud.com";
|
|
|
|
userName = address;
|
2023-09-30 09:27:43 +01:00
|
|
|
passwordCommand =
|
|
|
|
"${pkgs.libsecret}/bin/secret-tool lookup email ${userName}";
|
2023-09-29 09:28:11 +01:00
|
|
|
imapnotify = {
|
2023-10-01 12:04:09 +01:00
|
|
|
enable = lib.mkDefault accountEnabled;
|
2023-09-29 09:28:11 +01:00
|
|
|
boxes = [ "INBOX" ];
|
2023-10-04 16:39:34 +01:00
|
|
|
onNotify = "${pkgs.isync}/bin/mbsync --pull-new icloud:INBOX";
|
2023-09-29 14:55:18 +01:00
|
|
|
onNotifyPost =
|
2023-10-04 09:53:38 +01:00
|
|
|
"${pkgs.libnotify}/bin/notify-send 'iCloud: New mail arrived'";
|
2023-09-30 10:11:58 +01:00
|
|
|
extraConfig.wait = 300;
|
2023-09-29 09:28:11 +01:00
|
|
|
};
|
2023-09-25 17:59:40 +01:00
|
|
|
mbsync = {
|
2023-10-01 12:04:09 +01:00
|
|
|
enable = lib.mkDefault accountEnabled;
|
2023-09-25 17:59:40 +01:00
|
|
|
create = "both";
|
|
|
|
expunge = "both";
|
|
|
|
remove = "both";
|
|
|
|
patterns = [ "*" "!Junk" ];
|
|
|
|
subFolders = "Verbatim";
|
|
|
|
};
|
2023-10-01 12:04:09 +01:00
|
|
|
msmtp.enable = lib.mkDefault accountEnabled;
|
|
|
|
mu.enable = lib.mkDefault accountEnabled;
|
2023-09-25 17:59:40 +01:00
|
|
|
};
|
2023-09-29 09:55:52 +01:00
|
|
|
ukaea = let
|
|
|
|
host = "127.0.0.1";
|
|
|
|
tls.enable = false;
|
2023-10-04 09:53:38 +01:00
|
|
|
accountEnabled = true;
|
2023-09-29 09:55:52 +01:00
|
|
|
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;
|
2023-09-30 09:27:43 +01:00
|
|
|
passwordCommand =
|
|
|
|
"${pkgs.libsecret}/bin/secret-tool lookup email ${userName}";
|
2023-09-29 09:55:52 +01:00
|
|
|
imapnotify = {
|
2023-10-01 12:04:09 +01:00
|
|
|
enable = lib.mkDefault accountEnabled;
|
2023-09-29 09:55:52 +01:00
|
|
|
boxes = [ "INBOX" ];
|
2023-10-04 16:39:34 +01:00
|
|
|
onNotify = "${pkgs.isync}/bin/mbsync --pull-new ukaea:INBOX";
|
2023-09-29 14:55:18 +01:00
|
|
|
onNotifyPost =
|
2023-10-04 09:53:38 +01:00
|
|
|
"${pkgs.libnotify}/bin/notify-send 'UKAEA: New mail arrived'";
|
2023-09-29 09:55:52 +01:00
|
|
|
extraConfig = {
|
2023-09-30 10:11:58 +01:00
|
|
|
wait = 300;
|
2023-09-29 09:55:52 +01:00
|
|
|
tls = false;
|
|
|
|
tlsOptions.rejectUnauthorized = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
mbsync = {
|
2023-10-01 12:04:09 +01:00
|
|
|
enable = lib.mkDefault accountEnabled;
|
2023-09-29 09:55:52 +01:00
|
|
|
create = "both";
|
|
|
|
expunge = "both";
|
|
|
|
remove = "both";
|
|
|
|
patterns =
|
|
|
|
[ "*" "!Junk" "!Snoozed" "!Sync Issues" "!Unsent Messages" ];
|
|
|
|
subFolders = "Verbatim";
|
|
|
|
extraConfig.account.AuthMechs = "LOGIN";
|
|
|
|
};
|
2023-10-03 09:24:43 +01:00
|
|
|
msmtp = {
|
2023-10-01 12:04:09 +01:00
|
|
|
enable = lib.mkDefault accountEnabled;
|
2023-10-03 09:24:43 +01:00
|
|
|
extraConfig = {
|
|
|
|
tls = "off";
|
|
|
|
auth = "login";
|
|
|
|
};
|
2023-09-29 09:55:52 +01:00
|
|
|
};
|
2023-10-01 12:04:09 +01:00
|
|
|
mu.enable = lib.mkDefault accountEnabled;
|
2023-09-29 09:55:52 +01:00
|
|
|
};
|
2023-09-25 17:59:40 +01:00
|
|
|
};
|
2023-09-02 08:41:07 +01:00
|
|
|
};
|
2023-10-03 07:59:00 +01:00
|
|
|
systemd.user.services = let emailAccounts = config.accounts.email.accounts;
|
|
|
|
in {
|
|
|
|
imapnotify-proton.Unit = lib.mkIf emailAccounts.proton.imapnotify.enable {
|
2023-10-02 06:26:54 +01:00
|
|
|
Wants = [ "protonmail-bridge.service" ];
|
|
|
|
After = [ "protonmail-bridge.service" ];
|
|
|
|
};
|
2023-10-03 07:59:00 +01:00
|
|
|
imapnotify-ukaea.Unit = lib.mkIf emailAccounts.ukaea.imapnotify.enable {
|
2023-10-02 06:26:54 +01:00
|
|
|
Wants = [ "davmail.service" ];
|
|
|
|
After = [ "davmail.service" ];
|
|
|
|
};
|
2023-10-03 07:59:00 +01:00
|
|
|
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";
|
2023-10-01 09:17:45 +01:00
|
|
|
};
|
2023-10-03 07:59:00 +01:00
|
|
|
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.ukaea.mbsync.enable {
|
2023-10-01 09:17:45 +01:00
|
|
|
Unit = {
|
2023-10-02 16:58:54 +01:00
|
|
|
Description = "Davmail server";
|
2023-10-04 16:39:34 +01:00
|
|
|
Wants = [ "network-online.target" "hyprland-session.target" ];
|
|
|
|
After = [ "network-online.target" "hyprland-session.target" ];
|
2023-10-01 09:17:45 +01:00
|
|
|
};
|
|
|
|
Service = {
|
2023-10-02 16:58:54 +01:00
|
|
|
Environment = [ "PATH=/run/current-system/sw/bin/:$PATH" ];
|
2023-10-01 09:17:45 +01:00
|
|
|
Restart = "always";
|
2023-10-02 16:58:54 +01:00
|
|
|
ExecStart = "${pkgs.davmail}/bin/davmail -notray";
|
2023-10-01 09:17:45 +01:00
|
|
|
};
|
2023-10-02 06:26:54 +01:00
|
|
|
Install.WantedBy = [ "default.target" ];
|
2023-10-01 09:17:45 +01:00
|
|
|
};
|
|
|
|
};
|
2023-09-02 08:41:07 +01:00
|
|
|
}
|