From 7ef530000efea9173bf10b687ecd895625c1958c Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 15 Oct 2019 20:05:03 +0000 Subject: modules/mail: run notmuch after mbsync Doesn't really make sense to call this service "mbsync" any more. It might be better to run notmuch on inotify, though... --- modules/workstation/mail/default.nix | 34 +++++++++++++++++++++++-- modules/workstation/mail/isync/default.nix | 41 ------------------------------ modules/workstation/mail/isync/mbsyncrc.in | 22 ---------------- modules/workstation/mail/mbsyncrc.in | 22 ++++++++++++++++ 4 files changed, 54 insertions(+), 65 deletions(-) delete mode 100644 modules/workstation/mail/isync/default.nix delete mode 100644 modules/workstation/mail/isync/mbsyncrc.in create mode 100644 modules/workstation/mail/mbsyncrc.in (limited to 'modules/workstation/mail') diff --git a/modules/workstation/mail/default.nix b/modules/workstation/mail/default.nix index 0e8f341fa320..4564a2dee1c9 100644 --- a/modules/workstation/mail/default.nix +++ b/modules/workstation/mail/default.nix @@ -1,7 +1,37 @@ -{ pkgs, ... }: +{ pkgs, config, ... }: + +let + maildir = "${config.users.users.qyliss.home}/mail"; + mbsyncrc = pkgs.substituteAll { inherit maildir; src = ./mbsyncrc.in; }; + +in { - imports = [ ./isync ./msmtp ./mutt ./notmuch ]; + imports = [ ./msmtp ./mutt ./notmuch ]; + + environment.systemPackages = with pkgs; [ isync ]; + + systemd.services.mail = { + path = with pkgs; [ coreutils findutils isync notmuch sudo ]; + serviceConfig.Type = "oneshot"; + script = "sudo -u qyliss-mail mbsync -a -V -c ${mbsyncrc}"; + postStart = '' + find "${maildir}" \! -name .mbsyncstate* \ + \( \( \! -user qyliss -o \! -group qyliss \) , \ + -type f \! -perm 660 -exec chmod 0660 '{}' \; , \ + -type d \! -perm 770 -exec chmod 0770 '{}' \; \) + sudo -u qyliss \ + env NOTMUCH_CONFIG=/etc/xdg/nixos/per-user/qyliss/notmuch/config \ + notmuch new + ''; + }; + + systemd.timers.mail = { + timerConfig.OnCalendar = "*:0/5"; + timerConfig.Persistent = true; + after = [ "network-online.target" ]; + wantedBy = [ "timers.target" ]; + }; users.users.qyliss-mail = { home = "/var/home/qyliss-mail"; diff --git a/modules/workstation/mail/isync/default.nix b/modules/workstation/mail/isync/default.nix deleted file mode 100644 index ee384434f8d8..000000000000 --- a/modules/workstation/mail/isync/default.nix +++ /dev/null @@ -1,41 +0,0 @@ -{ pkgs, config, ... }: - - -{ - environment.systemPackages = with pkgs; [ isync ]; - - systemd.services.isync = - let - maildir = "${config.users.users.qyliss.home}/mail"; - mbsyncrc = pkgs.substituteAll { inherit maildir; src = ./mbsyncrc.in; }; - in with pkgs; { - serviceConfig.Type = "oneshot"; - script = '' - ${sudo}/bin/sudo -u qyliss-mail \ - ${isync}/bin/mbsync -a -V -c ${mbsyncrc} - ''; - postStart = '' - ${findutils}/bin/find \ - "${maildir}" \ - \! -name .mbsyncstate* \ - \( \ - \( \! -user qyliss -o \! -group qyliss \) \ - -exec ${coreutils}/bin/chown qyliss:qyliss '{}' \; \ - , \ - -type f \! -perm 660 \ - -exec ${coreutils}/bin/chmod 0660 '{}' \; \ - , \ - -type d \! -perm 770 \ - -exec ${coreutils}/bin/chmod 0770 '{}' \; \ - \) - ''; - }; - - systemd.timers.isync = { - timerConfig.Unit = "isync.service"; - timerConfig.OnCalendar = "*:0/5"; - timerConfig.Persistent = "true"; - after = [ "network-online.target" ]; - wantedBy = [ "timers.target" ]; - }; -} diff --git a/modules/workstation/mail/isync/mbsyncrc.in b/modules/workstation/mail/isync/mbsyncrc.in deleted file mode 100644 index 987646dd9e66..000000000000 --- a/modules/workstation/mail/isync/mbsyncrc.in +++ /dev/null @@ -1,22 +0,0 @@ -Create Both - -MaildirStore local - Path @maildir@/ - Inbox @maildir@/INBOX - Subfolders Verbatim - -IMAPAccount fastmail - Host imap.fastmail.com - User alyssa@fastmail.com - PassCmd "cat ~/imappass" - SSLType IMAPS - SSLVersions TLSv1.2 - -IMAPStore fastmail-remote - Account fastmail - -Channel fastmail - Master :fastmail-remote: - Slave :local: - Patterns * - SyncState * diff --git a/modules/workstation/mail/mbsyncrc.in b/modules/workstation/mail/mbsyncrc.in new file mode 100644 index 000000000000..987646dd9e66 --- /dev/null +++ b/modules/workstation/mail/mbsyncrc.in @@ -0,0 +1,22 @@ +Create Both + +MaildirStore local + Path @maildir@/ + Inbox @maildir@/INBOX + Subfolders Verbatim + +IMAPAccount fastmail + Host imap.fastmail.com + User alyssa@fastmail.com + PassCmd "cat ~/imappass" + SSLType IMAPS + SSLVersions TLSv1.2 + +IMAPStore fastmail-remote + Account fastmail + +Channel fastmail + Master :fastmail-remote: + Slave :local: + Patterns * + SyncState * -- cgit 1.4.1