2021-10-10 11:58:25 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2022-03-23 12:33:15 +01:00
|
|
|
|
|
|
|
with lib;
|
2022-02-15 16:40:23 +01:00
|
|
|
let
|
2022-03-23 12:33:15 +01:00
|
|
|
cfg = config.modules.desktop.apps.email;
|
2022-02-15 16:40:23 +01:00
|
|
|
name = "Moritz Böhme";
|
|
|
|
email = "mail@moritzboeh.me";
|
|
|
|
mailDirectory = "/home/moritz/.mail";
|
|
|
|
in {
|
2022-03-23 12:33:15 +01:00
|
|
|
options.modules.desktop.apps.email = {
|
|
|
|
enable = mkEnableOption "email module";
|
|
|
|
passwordFile = mkOption {
|
|
|
|
default = null;
|
|
|
|
type = types.path;
|
|
|
|
description = "File containing the email password.";
|
|
|
|
};
|
2021-10-10 11:58:25 +02:00
|
|
|
};
|
2022-03-23 12:33:15 +01:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# Protonbridge Setup
|
|
|
|
environment.systemPackages = with pkgs; [ protonmail-bridge ];
|
|
|
|
systemd.user.services.protonmail-bridge = {
|
|
|
|
description = "Protonmail Bridge";
|
|
|
|
enable = true;
|
|
|
|
script =
|
|
|
|
"${pkgs.protonmail-bridge}/bin/protonmail-bridge --log-level debug";
|
|
|
|
path = [
|
|
|
|
pkgs.gnome3.gnome-keyring
|
|
|
|
]; # HACK: https://github.com/ProtonMail/proton-bridge/issues/176
|
|
|
|
wantedBy = [ "graphical-session.target" ];
|
|
|
|
partOf = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
age.secrets.email = {
|
|
|
|
file = cfg.passwordFile;
|
|
|
|
owner = "1000";
|
2022-02-15 16:40:23 +01:00
|
|
|
};
|
|
|
|
|
2022-03-23 12:33:15 +01:00
|
|
|
# Email Applications
|
|
|
|
home-manager.users.moritz = {
|
|
|
|
home = { packages = with pkgs; [ thunderbird ]; };
|
|
|
|
programs = {
|
|
|
|
msmtp.enable = true;
|
|
|
|
mbsync.enable = true;
|
2022-02-15 16:40:23 +01:00
|
|
|
};
|
|
|
|
|
2022-03-23 12:33:15 +01:00
|
|
|
services = {
|
|
|
|
mbsync = {
|
|
|
|
enable = true;
|
|
|
|
frequency = "*:0/15";
|
|
|
|
preExec = "${pkgs.isync}/bin/mbsync -Ha";
|
|
|
|
postExec = "${pkgs.mu}/bin/mu index -m ${mailDirectory}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
accounts.email = {
|
|
|
|
maildirBasePath = mailDirectory;
|
|
|
|
accounts = {
|
|
|
|
default = {
|
|
|
|
address = email;
|
|
|
|
userName = email;
|
|
|
|
flavor = "plain";
|
|
|
|
primary = true;
|
|
|
|
passwordCommand = "${pkgs.coreutils}/bin/cat /run/agenix/email";
|
|
|
|
mbsync = {
|
2022-02-15 16:40:23 +01:00
|
|
|
enable = true;
|
2022-03-23 12:33:15 +01:00
|
|
|
create = "both";
|
|
|
|
expunge = "both";
|
|
|
|
patterns = [ "*" ];
|
2022-02-15 16:40:23 +01:00
|
|
|
};
|
2022-03-23 12:33:15 +01:00
|
|
|
realName = name;
|
|
|
|
msmtp.enable = true;
|
|
|
|
imap = {
|
|
|
|
host = "127.0.0.1";
|
|
|
|
port = 1143;
|
|
|
|
tls = {
|
|
|
|
enable = true;
|
|
|
|
useStartTls = true;
|
|
|
|
certificatesFile =
|
|
|
|
"/home/moritz/.config/protonmail/bridge/cert.pem";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
smtp = {
|
|
|
|
host = "127.0.0.1";
|
|
|
|
port = 1025;
|
|
|
|
tls = {
|
|
|
|
enable = true;
|
|
|
|
useStartTls = true;
|
|
|
|
certificatesFile =
|
|
|
|
"/home/moritz/.config/protonmail/bridge/cert.pem";
|
|
|
|
};
|
2022-02-15 16:40:23 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-03-23 12:33:15 +01:00
|
|
|
networking.firewall.allowedTCPPorts = [ 33728 1025 1143 ];
|
2022-02-15 16:40:23 +01:00
|
|
|
};
|
2021-10-10 11:58:25 +02:00
|
|
|
}
|