2022-11-09 21:20:33 -05:00
|
|
|
{ config, nixosConfig, lib, pkgs, inputs, ... }:
|
2022-07-02 16:15:19 -04:00
|
|
|
|
|
|
|
with lib; {
|
|
|
|
config = mkIf config.nathan.services.email.enable {
|
|
|
|
# Packages used for mbsync + mu + protonmail-bridge
|
2022-11-09 21:20:33 -05:00
|
|
|
home.packages = with pkgs; [
|
|
|
|
pass
|
|
|
|
protonmail-bridge
|
|
|
|
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.mu
|
|
|
|
];
|
2022-07-02 16:15:19 -04:00
|
|
|
# Configure protonmail as a service
|
|
|
|
systemd.user.services.protonmail-bridge = {
|
|
|
|
Unit = {
|
|
|
|
Description = "Proton Mail Bridge";
|
|
|
|
After = [ "graphical-session-pre.target" ];
|
|
|
|
Before = [ "mbsync.service" ];
|
|
|
|
PartOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
Service = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = ''
|
|
|
|
${pkgs.protonmail-bridge}/bin/protonmail-bridge --noninteractive
|
|
|
|
'';
|
|
|
|
};
|
2022-10-02 21:37:05 -04:00
|
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
2022-07-02 16:15:19 -04:00
|
|
|
};
|
2022-11-10 11:30:39 -05:00
|
|
|
# Setup files we need for email to work
|
|
|
|
home.file = {
|
|
|
|
".local/nathan-home/proton.pem" = {
|
|
|
|
source =
|
|
|
|
../../../certificates/protonmail-${nixosConfig.networking.hostName}.pem;
|
|
|
|
};
|
|
|
|
".local/nathan-home/sync-mu4e.sh" = {
|
|
|
|
source = ../../../scripts/update-mu4e.sh;
|
|
|
|
executable = true;
|
|
|
|
};
|
|
|
|
};
|
2022-07-02 16:15:19 -04:00
|
|
|
# Setup accounts
|
|
|
|
accounts.email = {
|
|
|
|
maildirBasePath = ".mail";
|
|
|
|
accounts = {
|
|
|
|
"nathan@mccarty.io" = {
|
2022-10-13 22:13:43 -04:00
|
|
|
maildir = { path = "nathan@mccarty.io"; };
|
2022-07-02 16:15:19 -04:00
|
|
|
address = "nathan@mccarty.io";
|
|
|
|
primary = true;
|
|
|
|
realName = "Nathan McCarty";
|
|
|
|
userName = "nathan@mccarty.io";
|
|
|
|
passwordCommand = "${pkgs.pass}/bin/pass protonmail-bridge-password";
|
|
|
|
aliases = [
|
|
|
|
"thatonelutenist@protonmail.com"
|
|
|
|
"nathan@asuran.rs"
|
|
|
|
"nathan@community.rs"
|
|
|
|
];
|
|
|
|
imap = {
|
|
|
|
host = "127.0.0.1";
|
|
|
|
port = 1143;
|
|
|
|
tls = {
|
|
|
|
useStartTls = true;
|
2022-10-13 22:13:43 -04:00
|
|
|
certificatesFile =
|
2022-11-10 11:30:39 -05:00
|
|
|
"${config.home.homeDirectory}/.local/nathan-home/proton.pem";
|
2022-07-02 16:15:19 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
smtp = {
|
|
|
|
host = "127.0.0.1";
|
|
|
|
port = 1025;
|
|
|
|
tls = {
|
|
|
|
useStartTls = true;
|
2022-10-13 22:13:43 -04:00
|
|
|
certificatesFile =
|
2022-11-10 11:30:39 -05:00
|
|
|
"${config.home.homeDirectory}/.local/nathan-home/proton.pem";
|
2022-07-02 16:15:19 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
mbsync = {
|
|
|
|
enable = true;
|
2022-12-02 18:41:57 -05:00
|
|
|
create = "both";
|
2022-07-06 01:15:21 -04:00
|
|
|
remove = "both";
|
2022-12-02 18:41:57 -05:00
|
|
|
expunge = "both";
|
|
|
|
patterns =
|
|
|
|
[ "INBOX" "Folders/*" "Sent" "Drafts" "Spam" "Trash" "Archive" ];
|
2022-07-02 16:15:19 -04:00
|
|
|
};
|
2022-10-13 22:13:43 -04:00
|
|
|
msmtp = { enable = true; };
|
2022-07-02 16:15:19 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-07-02 22:36:59 -04:00
|
|
|
## Enable email applications
|
|
|
|
# Setup mbsync for incoming emails
|
|
|
|
# For fun reasons this requires enabling the program and the service
|
2022-10-13 22:13:43 -04:00
|
|
|
programs.mbsync = { enable = true; };
|
2022-07-02 16:15:19 -04:00
|
|
|
services.mbsync = {
|
|
|
|
enable = true;
|
2022-12-02 18:41:57 -05:00
|
|
|
frequency = "*:0/5";
|
2022-07-04 01:17:05 -04:00
|
|
|
# Index manually with mu if we don't have emacs setup, but if we have the emacs service setup,
|
|
|
|
# run through emacsclient, as it will have the lock
|
2022-10-13 22:13:43 -04:00
|
|
|
postExec = if config.nathan.programs.emacs.service then
|
2022-11-10 11:30:39 -05:00
|
|
|
"${config.home.homeDirectory}/.local/nathan-home/sync-mu4e.sh"
|
2022-10-13 22:13:43 -04:00
|
|
|
else
|
2022-11-09 21:20:33 -05:00
|
|
|
"${
|
|
|
|
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.mu
|
|
|
|
}/bin/mu index";
|
2022-07-02 16:15:19 -04:00
|
|
|
};
|
2022-07-02 22:36:59 -04:00
|
|
|
# Setup msmtp for outbound emails
|
2022-10-13 22:13:43 -04:00
|
|
|
programs.msmtp = { enable = true; };
|
2022-07-02 16:15:19 -04:00
|
|
|
};
|
|
|
|
}
|