Commit 5c966c76a098

Vincent Demeester <vincent@sbr.pm>
2026-01-29 11:04:37
fix(mails): wrap mbsync postExec in shell script
Systemd ExecStartPost doesn't support multi-line scripts inline. Wrap the postExec script using writeShellScript to generate a proper script file that systemd can execute. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6164c7a
Changed files (1)
home
common
desktop
home/common/desktop/mails.nix
@@ -102,15 +102,17 @@
   services.mbsync = {
     enable = true;
     frequency = "*:0/15"; # Every 15 minutes
-    postExec = ''
-      # Update mu index after sync
-      # Use emacsclient if mu4e is running to avoid lock conflicts
-      if ${pkgs.procps}/bin/pgrep -u $UID mu >/dev/null 2>&1; then
-        ${pkgs.emacs}/bin/emacsclient --eval '(mu4e-update-index)' 2>/dev/null || true
-      else
-        ${pkgs.mu}/bin/mu index --quiet
-      fi
-    '';
+    postExec = toString (
+      pkgs.writeShellScript "mbsync-post" ''
+        # Update mu index after sync
+        # Use emacsclient if mu4e is running to avoid lock conflicts
+        if ${pkgs.procps}/bin/pgrep -u $UID mu >/dev/null 2>&1; then
+          ${pkgs.emacs}/bin/emacsclient --eval '(mu4e-update-index)' 2>/dev/null || true
+        else
+          ${pkgs.mu}/bin/mu index --quiet
+        fi
+      ''
+    );
   };
   programs.mu = {
     enable = true;