nixos/system/home/services/email/default.nix
Evie Litherland-Smith 5ff572a9b7 Major rewrite/refactor to simplify things
Move home/ directory under system/ directory. Remove duplicated
machine-specific config files, now handled as one per host (excluding
hardware-configuration directory)

Move as much configuration as possible out of flake.nix and into more
appropriate files (e.g. system/default.nix)

Add a desktop.nix and laptop.nix for system, both will import
home/desktop.nix and home/laptop.nix respectively to reduce
duplication in machine-specific config files

Remove games and streaming directories, moved directly into Vanguard
config file

Remove home/personal.nix since it ended up being empty after changes

Remove old sway config since I haven't been maintaining it and this
refactor will definitely break it
2024-08-30 12:57:02 +01:00

181 lines
5.2 KiB
Nix

{ config, pkgs, ... }:
{
home.packages = [
pkgs.protonmail-bridge-gui
(pkgs.writeShellScriptBin "mbsync-ensure-pass" (builtins.readFile ./mbsync-ensure-pass.sh))
(pkgs.writeShellScriptBin "davmail-setup" ''
systemctl --user restart davmail # Ensure config file is present
systemctl --user stop davmail
${pkgs.davmail}/bin/davmail -n ~/.davmail.properties
systemctl --user restart davmail
'')
];
xdg.configFile."protonmail/bridge-v3/keychain.json".text = builtins.toJSON {
Helper = "secret-service-dbus";
};
accounts.email = {
maildirBasePath = "Mail";
accounts =
let
realName = "Evie Litherland-Smith";
in
{
proton =
let
address = "e.litherlandsmith@proton.me";
host = "127.0.0.1";
tls.enable = false;
in
{
inherit realName address;
primary = true;
maildir.path = "Proton";
imap = {
inherit host tls;
port = 1143;
};
smtp = {
inherit host tls;
port = 1025;
};
aliases = [
"evie@xenia.me.uk"
"evie@litherlandsmith.slmail.me"
];
userName = address;
passwordCommand = "${pkgs.libsecret}/bin/secret-tool lookup email ${address}";
mu.enable = true;
msmtp = {
enable = true;
extraConfig = {
tls = "off";
auth = "login";
};
};
mbsync = {
enable = true;
create = "both";
expunge = "both";
remove = "both";
patterns = [
"*"
"!All Mail"
"!Labels*"
"!Starred"
"!Recovered Messages"
];
subFolders = "Verbatim";
extraConfig.account.AuthMechs = "LOGIN";
};
};
icloud =
let
address = "e.litherlandsmith@icloud.com";
in
{
inherit realName address;
primary = false;
maildir.path = "iCloud";
imap.host = "imap.mail.me.com";
smtp.host = "smtp.mail.me.com";
userName = address;
passwordCommand = "${pkgs.libsecret}/bin/secret-tool lookup email ${address}";
mu.enable = true;
msmtp.enable = true;
mbsync = {
enable = true;
create = "both";
expunge = "both";
remove = "both";
patterns = [
"*"
"!Notes"
];
subFolders = "Verbatim";
};
};
outlook =
let
address = "evie.litherland-smith@ukaea.uk";
host = "127.0.0.1";
tls.enable = false;
in
{
inherit realName address;
primary = false;
maildir.path = "Outlook";
imap = {
inherit host tls;
port = 1144;
};
smtp = {
inherit host tls;
port = 1026;
};
aliases = [ "elitherl@jet.uk" ];
userName = address;
passwordCommand = "${pkgs.libsecret}/bin/secret-tool lookup email ${address}";
mu.enable = true;
msmtp = {
enable = true;
extraConfig = {
tls = "off";
auth = "login";
};
};
mbsync = {
enable = true;
create = "both";
expunge = "both";
remove = "both";
patterns = [
"*"
"!Conversation History"
"!Snoozed"
"!Social Activity Notifications"
"!Sync Issues*"
"!Unsent Messages"
];
subFolders = "Verbatim";
extraConfig.account.AuthMechs = "LOGIN";
};
};
};
};
programs = {
mu.enable = true;
msmtp.enable = true;
mbsync = {
enable = true;
groups.inboxes = {
proton = [ "INBOX" ];
icloud = [ "INBOX" ];
outlook = [ "INBOX" ];
};
};
};
services.mbsync = {
inherit (config.programs.mbsync) enable package;
frequency = "*:0/5"; # Every 5 minutes
verbose = true;
preExec = null;
postExec = null;
};
systemd.user.services.davmail = {
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" ];
};
}