From ed2a896cff9a167cbcaf6802ab08facbb7947dff Mon Sep 17 00:00:00 2001 From: Grigory Shipunov Date: Fri, 12 Aug 2022 00:31:42 +0200 Subject: automatic mail sync --- modules/mail/default.nix | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 modules/mail/default.nix (limited to 'modules/mail/default.nix') diff --git a/modules/mail/default.nix b/modules/mail/default.nix new file mode 100644 index 0000000..55e58c7 --- /dev/null +++ b/modules/mail/default.nix @@ -0,0 +1,88 @@ +{ config, pkgs, ... }: +let + mbsyncConf = ./mbsyncrc; +in +{ + environment.systemPackages = with pkgs; [ + isync + msmtp + neomutt + notmuch + pass + w3m + ]; + + 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; + }; + }; + + programs.msmtp = { + enable = true; + setSendmail = true; + defaults = { + tls_trust_file = "/etc/ssl/certs/ca-certificates.crt"; + logfile = "/tmp/msmtp.log"; + }; + accounts = { + "mail@oxapentane.com" = { + host = "smtp.migadu.com"; + port = 578; + from = "*@oxapentane.com"; + user = "mail@oxapentane.com"; + passwordeval = "cat ${config.sops.secrets."mail/oxapentane.com".path}"; + auth = "on"; + tls = "on"; + }; + "grigory@shipunov.xyz" = { + host = "smtp.migadu.com"; + port = 578; + from = "*@shipunov.xyz"; + user = "mail@oxapentane.com"; + passwordeval = "cat ${config.sops.secrets."mail/shipunov.xyz".path}"; + auth = "on"; + tls = "on"; + }; + "dump@dvb.solutions" = { + host = "smtp.migadu.com"; + port = 578; + from = "dump@dvb.solutions"; + user = "dump@dvb.solutions"; + passwordeval = "cat ${config.sops.secrets."mail/dvb.solutions".path}"; + auth = "on"; + tls = "on"; + }; + }; + }; +systemd.user = { + + services.mbsync = { + enable = true; + after = [ "graphical.target" "network-online.target" ]; + script = '' + ${pkgs.isync}/bin/mbsync -a --config=${mbsyncConf} + ''; + serviceConfig = { + Type = "oneshot"; + }; + }; + + timers.mbsync = { + enable = true; + wantedBy = [ "timers.target" ]; + timerConfig = { + Unit = "mbsync.service"; + OnUnitInactiveSec = "11m"; + Persistent = true; + }; + }; + + }; +} -- cgit v1.3.1