about summary refs log tree commit diff
path: root/modules/workstation/mail/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-10-15 20:05:03 +0000
committerAlyssa Ross <hi@alyssa.is>2019-10-15 20:09:41 +0000
commit7ef530000efea9173bf10b687ecd895625c1958c (patch)
treeeab38a3c15dace4dbf67cbe1e3f0a9788916bced /modules/workstation/mail/default.nix
parentff6f4aed93ab7ac091fb007a3ec6958999e5a0ef (diff)
downloadnixlib-7ef530000efea9173bf10b687ecd895625c1958c.tar
nixlib-7ef530000efea9173bf10b687ecd895625c1958c.tar.gz
nixlib-7ef530000efea9173bf10b687ecd895625c1958c.tar.bz2
nixlib-7ef530000efea9173bf10b687ecd895625c1958c.tar.lz
nixlib-7ef530000efea9173bf10b687ecd895625c1958c.tar.xz
nixlib-7ef530000efea9173bf10b687ecd895625c1958c.tar.zst
nixlib-7ef530000efea9173bf10b687ecd895625c1958c.zip
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...
Diffstat (limited to 'modules/workstation/mail/default.nix')
-rw-r--r--modules/workstation/mail/default.nix34
1 files changed, 32 insertions, 2 deletions
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";