Fix accidentally disabling work email on work machines...

Move work email config to separate work.nix file in email directory,
remove the if block dependencies on mu status since that doesn't get
update if mu.enable is changed in another file!
This commit is contained in:
Evie Litherland-Smith 2024-03-11 15:35:01 +00:00
parent e60532eb13
commit 6aae3e131f
4 changed files with 82 additions and 81 deletions

View file

@ -20,7 +20,6 @@
};
outputs = {
self,
nixpkgs,
home-manager,
stylix,
@ -210,6 +209,7 @@
];
homeModules = [
./home/hyprland/default.nix
./home/email/work.nix
];
};
@ -221,6 +221,7 @@
];
homeModules = [
./home/hyprland/default.nix
./home/email/work.nix
];
};
};

View file

@ -1,6 +1,4 @@
{
config,
lib,
pkgs,
hostName,
...
@ -15,7 +13,7 @@
tls.enable = false;
in rec {
inherit realName;
primary = lib.mkDefault true;
primary = true;
maildir.path = "Proton";
imap = {
inherit host tls;
@ -29,16 +27,16 @@
aliases = ["evie@xenia.me.uk" "evie@litherlandsmith.slmail.me"];
userName = address;
passwordCommand = "${pkgs.pass}/bin/pass show mbsync/${hostName}/proton | head -n1";
mu.enable = lib.mkDefault true;
mu.enable = true;
msmtp = {
enable = mu.enable;
enable = true;
extraConfig = {
tls = "off";
auth = "login";
};
};
mbsync = {
enable = mu.enable;
enable = true;
create = "both";
expunge = "both";
remove = "both";
@ -49,17 +47,17 @@
};
icloud = rec {
inherit realName;
primary = lib.mkDefault false;
primary = 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.pass}/bin/pass show mbsync/${hostName}/icloud | head -n1";
mu.enable = lib.mkDefault true;
msmtp.enable = mu.enable;
mu.enable = true;
msmtp.enable = true;
mbsync = {
enable = mu.enable;
enable = true;
create = "both";
expunge = "both";
remove = "both";
@ -67,50 +65,6 @@
subFolders = "Verbatim";
};
};
outlook = let
host = "127.0.0.1";
tls.enable = false;
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.pass}/bin/pass show mbsync/${hostName}/outlook | head -n1";
mu.enable = lib.mkDefault false;
msmtp = {
enable = mu.enable;
extraConfig = {
tls = "off";
auth = "login";
};
};
mbsync = {
enable = mu.enable;
create = "both";
expunge = "both";
remove = "both";
patterns = [
"*"
"!Conversation History"
"!Snoozed"
"!Social Activity Notifications"
"!Sync Issues*"
"!Unsent Messages"
];
subFolders = "Verbatim";
extraConfig.account.AuthMechs = "LOGIN";
};
};
};
};
programs = {
@ -121,28 +75,7 @@
groups.inboxes = {
proton = ["INBOX"];
icloud = ["INBOX"];
outlook = ["INBOX"];
};
};
};
systemd.user.services = let
emailAccounts = config.accounts.email.accounts;
in {
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"];
};
};
}

69
home/email/work.nix Normal file
View file

@ -0,0 +1,69 @@
{
config,
pkgs,
hostName,
...
}: {
imports = [./default.nix];
accounts.email.accounts.outlook = let
host = "127.0.0.1";
tls.enable = false;
in rec {
inherit (config.accounts.email.accounts.proton) realName;
primary = 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.pass}/bin/pass show mbsync/${hostName}/outlook | head -n1";
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.mbsync.groups.inboxes.outlook = ["INBOX"];
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"];
};
}

View file

@ -1,16 +1,14 @@
{
config,
lib,
pkgs,
...
}: {
home.packages = [(pkgs.writeShellScriptBin "ukaea-vpn-connect" "sudo ${pkgs.openfortivpn}/bin/openfortivpn -c ${./ukaea-vpn.conf}")];
programs.git.userEmail = config.accounts.email.accounts.outlook.address;
accounts.email.accounts = {
proton.primary = false;
outlook = {
primary = true;
mu.enable = true;
};
proton.primary = lib.mkForce false;
outlook.primary = lib.mkForce true;
};
wayland.windowManager.hyprland.settings = {
misc.force_default_wallpaper = 0;