104 lines
3.3 KiB
Nix
104 lines
3.3 KiB
Nix
{ config, nixosConfig, lib, pkgs, inputs, ... }:
|
|
|
|
with lib; {
|
|
config = mkIf config.nathan.services.email.enable {
|
|
# Packages used for mbsync + mu + protonmail-bridge
|
|
home.packages = with pkgs; [
|
|
pass
|
|
protonmail-bridge
|
|
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.mu
|
|
];
|
|
# 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
|
|
'';
|
|
};
|
|
Install = { WantedBy = [ "graphical-session.target" ]; };
|
|
};
|
|
# 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;
|
|
};
|
|
};
|
|
# Setup accounts
|
|
accounts.email = {
|
|
maildirBasePath = ".mail";
|
|
accounts = {
|
|
"nathan@mccarty.io" = {
|
|
maildir = { path = "nathan@mccarty.io"; };
|
|
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;
|
|
certificatesFile =
|
|
"${config.home.homeDirectory}/.local/nathan-home/proton.pem";
|
|
};
|
|
};
|
|
smtp = {
|
|
host = "127.0.0.1";
|
|
port = 1025;
|
|
tls = {
|
|
useStartTls = true;
|
|
certificatesFile =
|
|
"${config.home.homeDirectory}/.local/nathan-home/proton.pem";
|
|
};
|
|
};
|
|
mbsync = {
|
|
enable = true;
|
|
create = "both";
|
|
remove = "both";
|
|
expunge = "both";
|
|
patterns =
|
|
[ "INBOX" "Folders/*" "Sent" "Drafts" "Spam" "Trash" "Archive" ];
|
|
};
|
|
msmtp = { enable = true; };
|
|
};
|
|
};
|
|
};
|
|
## Enable email applications
|
|
# Setup mbsync for incoming emails
|
|
# For fun reasons this requires enabling the program and the service
|
|
programs.mbsync = { enable = true; };
|
|
services.mbsync = {
|
|
enable = !config.nathan.programs.emacs.service;
|
|
frequency = "*:0/5";
|
|
# 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
|
|
postExec = if config.nathan.programs.emacs.service then
|
|
"${config.home.homeDirectory}/.local/nathan-home/sync-mu4e.sh"
|
|
else
|
|
"${
|
|
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.mu
|
|
}/bin/mu index";
|
|
};
|
|
# Setup msmtp for outbound emails
|
|
programs.msmtp = { enable = true; };
|
|
};
|
|
}
|