summaryrefslogtreecommitdiff
path: root/modules/mail
diff options
context:
space:
mode:
authorGrisha Shipunov2024-12-31 13:52:57 +0000
committerGrisha Shipunov2024-12-31 13:52:57 +0000
commit50066a4d208b83e63d5ebb4bc64e740e78deae59 (patch)
treeb09004fb2121e2ffb4d46bb45ff65b024749d7e2 /modules/mail
parent677abb734403d4f412dbbdc83f372cc606d9d519 (diff)
revert toaster
Diffstat (limited to 'modules/mail')
-rw-r--r--modules/mail/default.nix133
-rw-r--r--modules/mail/mbsyncrc97
2 files changed, 230 insertions, 0 deletions
diff --git a/modules/mail/default.nix b/modules/mail/default.nix
new file mode 100644
index 0000000..5225480
--- /dev/null
+++ b/modules/mail/default.nix
@@ -0,0 +1,133 @@
+{ config, pkgs, ... }:
+let
+ mbsyncConf = ./mbsyncrc;
+in
+{
+ environment.systemPackages = with pkgs; [
+ isync
+ msmtp
+ neomutt
+ notmuch
+ alot
+ w3m
+ links2
+ ];
+
+ environment.shellAliases = {
+ mutt = "neomutt";
+ };
+
+ 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;
+ };
+ "mail/tlm.solutions" = {
+ owner = config.users.users.grue.name;
+ };
+ };
+
+ programs.msmtp = {
+ enable = true;
+ setSendmail = true;
+ 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
+
+ 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
+ '';
+ };
+
+
+ systemd.user = {
+
+ # Service and timer to sync imap to local maildir
+ services.mbsync = {
+ enable = true;
+ after = [ "graphical.target" "network-online.target" ];
+ script = ''
+ ${pkgs.isync}/bin/mbsync -q -a --config=${mbsyncConf}
+ '';
+ serviceConfig = {
+ Type = "oneshot";
+ };
+ };
+
+ timers.mbsync = {
+ enable = true;
+ wantedBy = [ "timers.target" ];
+ timerConfig = {
+ Unit = "mbsync.service";
+ OnBootSec = "5m";
+ OnUnitInactiveSec = "11m";
+ };
+ };
+
+ # 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";
+ };
+ };
+
+ };
+}
diff --git a/modules/mail/mbsyncrc b/modules/mail/mbsyncrc
new file mode 100644
index 0000000..f34f390
--- /dev/null
+++ b/modules/mail/mbsyncrc
@@ -0,0 +1,97 @@
+IMAPStore mail@oxapentane.com-remote
+Host imap.migadu.com
+Port 993
+User mail@oxapentane.com
+PassCmd "cat /run/secrets/mail/oxapentane.com"
+AuthMechs LOGIN
+SSLType IMAPS
+
+MaildirStore mail@oxapentane.com-local
+Subfolders Verbatim
+Path /home/grue/mail/mail@oxapentane.com/
+Inbox /home/grue/mail/mail@oxapentane.com/INBOX
+
+Channel mail@oxapentane.com
+Expunge Both
+Master :mail@oxapentane.com-remote:
+Slave :mail@oxapentane.com-local:
+Create Both
+SyncState *
+Patterns *
+MaxMessages 0
+ExpireUnread no
+# End profile
+
+
+IMAPStore grigory@shipunov.xyz-remote
+Host imap.migadu.com
+Port 993
+User grigory@shipunov.xyz
+PassCmd "cat /run/secrets/mail/shipunov.xyz"
+AuthMechs LOGIN
+SSLType IMAPS
+
+MaildirStore grigory@shipunov.xyz-local
+Subfolders Verbatim
+Path /home/grue/mail/grigory@shipunov.xyz/
+Inbox /home/grue/mail/grigory@shipunov.xyz/INBOX
+
+Channel grigory@shipunov.xyz
+Expunge Both
+Master :grigory@shipunov.xyz-remote:
+Slave :grigory@shipunov.xyz-local:
+Create Both
+SyncState *
+Patterns *
+MaxMessages 0
+ExpireUnread no
+# End profile
+
+
+IMAPStore dump@dvb.solutions-remote
+Host imap.migadu.com
+Port 993
+User dump@dvb.solutions
+PassCmd "cat /run/secrets/mail/dvb.solutions"
+AuthMechs LOGIN
+SSLType IMAPS
+
+MaildirStore dump@dvb.solutions-local
+Subfolders Verbatim
+Path /home/grue/mail/dump@dvb.solutions/
+Inbox /home/grue/mail/dump@dvb.solutions/INBOX
+
+Channel dump@dvb.solutions
+Expunge Both
+Master :dump@dvb.solutions-remote:
+Slave :dump@dvb.solutions-local:
+Create Both
+SyncState *
+Patterns *
+MaxMessages 0
+ExpireUnread no
+# End profile
+
+IMAPStore grigory@tlm.solutions-remote
+Host imap.migadu.com
+Port 993
+User grigory@tlm.solutions
+PassCmd "cat /run/secrets/mail/tlm.solutions"
+AuthMechs LOGIN
+SSLType IMAPS
+
+MaildirStore grigory@tlm.solutions-local
+Subfolders Verbatim
+Path /home/grue/mail/grigory@tlm.solutions/
+Inbox /home/grue/mail/grigory@tlm.solutions/INBOX
+
+Channel grigory@tlm.solutions
+Expunge Both
+Master :grigory@tlm.solutions-remote:
+Slave :grigory@tlm.solutions-local:
+Create Both
+SyncState *
+Patterns *
+MaxMessages 0
+ExpireUnread no
+# End profile