nix-config/modules/mail/default.nix

129 lines
2.9 KiB
Nix
Raw Normal View History

2022-08-12 00:31:42 +02:00
{ config, pkgs, ... }:
let
mbsyncConf = ./mbsyncrc;
in
{
environment.systemPackages = with pkgs; [
isync
msmtp
neomutt
notmuch
w3m
2022-12-16 21:24:03 +01:00
links2
2022-08-12 00:31:42 +02:00
];
sops.secrets = {
"mail/oxapentane.com" = {
owner = config.users.users.grue.name;
};
"mail/shipunov.xyz" = {
owner = config.users.users.grue.name;
};
"mail/dvb.solutions" = {
owner = config.users.users.grue.name;
};
2023-01-08 03:11:13 +01:00
"mail/tlm.solutions" = {
owner = config.users.users.grue.name;
};
2022-08-12 00:31:42 +02:00
};
programs.msmtp = {
enable = true;
setSendmail = true;
2022-08-12 01:33:11 +02:00
extraConfig = ''
account mail@oxapentane.com
host smtp.migadu.com
port 587
from *@oxapentane.com
user mail@oxapentane.com
passwordeval cat ${config.sops.secrets."mail/oxapentane.com".path}
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
account grigory@shipunov.xyz
host smtp.migadu.com
port 587
from *@shipunov.xyz
user grigory@shipunov.xyz
passwordeval cat ${config.sops.secrets."mail/shipunov.xyz".path}
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
account dump@dvb.solutions
host smtp.migadu.com
port 587
from dump@dvb.solutions
user dump@dvb.solutions
passwordeval cat ${config.sops.secrets."mail/dvb.solutions".path}
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
2023-01-08 03:11:13 +01:00
account grigory@tlm.solutions
host smtp.migadu.com
port 587
from grigory@tlm.solutions
user grigory@tlm.solutions
passwordeval cat ${config.sops.secrets."mail/tlm.solutions".path}
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
2022-08-12 01:33:11 +02:00
'';
2022-08-12 00:31:42 +02:00
};
2022-08-12 01:33:11 +02:00
systemd.user = {
2022-08-12 00:31:42 +02:00
2023-02-13 14:31:11 +01:00
# Service and timer to sync imap to local maildir
2022-08-12 00:31:42 +02:00
services.mbsync = {
enable = true;
after = [ "graphical.target" "network-online.target" ];
script = ''
2022-08-13 14:08:09 +02:00
${pkgs.isync}/bin/mbsync -q -a --config=${mbsyncConf}
2022-08-12 00:31:42 +02:00
'';
serviceConfig = {
Type = "oneshot";
};
};
timers.mbsync = {
enable = true;
wantedBy = [ "timers.target" ];
timerConfig = {
Unit = "mbsync.service";
2022-08-19 10:55:03 +02:00
OnBootSec = "5m";
2022-08-12 00:31:42 +02:00
OnUnitInactiveSec = "11m";
};
};
2023-02-13 14:31:11 +01:00
# service and timer to flush the msmtp queue
services.flush-msmtpq = {
enable = true;
after = [ "graphical.target" "network-online.target" ];
script = ''
${pkgs.msmtp}/bin/msmtp-queue -r
'';
serviceConfig = {
Type = "oneshot";
};
};
timers.flush-msmtpq = {
enable = true;
wantedBy = [ "timers.target" ];
timerConfig = {
Unit = "flush-msmtpq.service";
OnBootSec = "11m";
OnUnitInactiveSec = "13m";
};
};
2022-08-12 00:31:42 +02:00
};
}