Commit 840df3ac1531

Vincent Demeester <vincent@sbr.pm>
2026-07-28 11:01:54
fix(mail): set passage and mu env vars for systemd services
Added PASSAGE_DIR and PASSAGE_IDENTITIES_FILE inline in passwordCommand so mbsync works under systemd (no session vars). Exported MUHOME in post-exec script and session variables to ensure mu uses the correct database path.
1 parent 9b23613
Changed files (1)
home
common
desktop
home/common/desktop/mails.nix
@@ -18,7 +18,7 @@ in
         address = "vincent@demeester.fr";
         userName = "vdemeester@icloud.com";
         realName = "Vincent Demeester";
-        passwordCommand = "${pkgs.passage}/bin/passage show mails/icloud/vdemeester";
+        passwordCommand = "PASSAGE_DIR=${config.xdg.dataHome}/passage PASSAGE_IDENTITIES_FILE=${config.xdg.dataHome}/passage/identities ${pkgs.passage}/bin/passage show mails/icloud/vdemeester";
         imap.host = "imap.mail.me.com";
         smtp.host = "smtp.mail.me.com";
         smtp.port = 587;
@@ -54,7 +54,7 @@ in
             address = "vdemeest@redhat.com";
             userName = "vdemeest@redhat.com";
             realName = "Vincent Demeester";
-            passwordCommand = "${pkgs.passage}/bin/passage show mails/gmail/redhat";
+            passwordCommand = "PASSAGE_DIR=${config.xdg.dataHome}/passage PASSAGE_IDENTITIES_FILE=${config.xdg.dataHome}/passage/identities ${pkgs.passage}/bin/passage show mails/gmail/redhat";
             imap.host = "imap.gmail.com";
             smtp.host = "smtp.gmail.com";
             flavor = "gmail.com";
@@ -108,6 +108,7 @@ in
     frequency = "*:0/15"; # Every 15 minutes
     postExec = toString (
       pkgs.writeShellScript "mbsync-post" ''
+        export MUHOME="${config.xdg.dataHome}/mu"
         # 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
@@ -124,6 +125,7 @@ in
     # across reboots and prevent re-indexing
     home = "${config.xdg.dataHome}/mu";
   };
+  home.sessionVariables.MUHOME = "${config.xdg.dataHome}/mu";
   home.packages = with pkgs; [ mblaze ];
 
   # Override the default mu init activation to prevent it from wiping the index