Commit 79a9d9c0ec93

Vincent Demeester <vincent@sbr.pm>
2026-06-29 17:08:55
feat(mail): enable work email on aomi
Migrated the Red Hat (gmail) account to the aomi Fedora workstation, previously gated to kyushu only. Work email is now available outside the soon-to-be-migrated NixOS host. - Gate the redhat account and mu work-address on a work-host predicate (kyushu or aomi) instead of kyushu alone - Import goimapnotify and mail-monitor services on aomi - Pass PASSAGE_DIR/PASSAGE_IDENTITIES_FILE to goimapnotify so passage passwordCmd resolves under systemd, which also fixed icloud IDLE sync - Build mu4e contexts conditionally on maildir presence so a host missing icloud or redhat no longer errors
1 parent 9677b97
Changed files (4)
dots
config
emacs
home
common
systems
dots/config/emacs/init.el
@@ -2844,7 +2844,14 @@ with quoted lines and signatures removed."
   ;; Open compose in a new frame
   (setq mu4e-compose-switch 'frame)
 
-  (setq mu4e-contexts `( ,(make-mu4e-context
+  ;; Build contexts only for accounts whose maildir actually exists on this
+  ;; host, so a machine missing icloud (or redhat) doesn't error out.
+  (setq mu4e-contexts
+	(let ((maildir-root (expand-file-name "~/desktop/mails")))
+	  (delq nil
+	   (list
+	    (when (file-directory-p (expand-file-name "icloud" maildir-root))
+	      (make-mu4e-context
 			   :name "icloud"
 			   :match-func (lambda (msg) (when msg
 						       (string-prefix-p "/icloud" (mu4e-message-field msg :maildir))))
@@ -2854,8 +2861,9 @@ with quoted lines and signatures removed."
 				   (mu4e-sent-folder . "/icloud/Sent Messages")
 				   (mu4e-draft-folder . "/icloud/Drafts")
 				   ;; (mu4e-get-mail-command . "mbsync icloud")
-				   ))
-			 ,(make-mu4e-context
+				   )))
+	    (when (file-directory-p (expand-file-name "redhat" maildir-root))
+	      (make-mu4e-context
 			   :name "redhat"
 			   :match-func (lambda (msg) (when msg
 						       (string-prefix-p "/redhat" (mu4e-message-field msg :maildir))))
@@ -2866,8 +2874,7 @@ with quoted lines and signatures removed."
 				   ;; (mu4e-refile-folder  . "/redhat/[Gmail]/All Mail")
 				   (mu4e-trash-folder  . "/redhat/[Gmail]/Trash")
 				   ;; (mu4e-get-mail-command . "mbsync redhat")
-				   ))
-			 ))
+				   )))))))
   ;; === Priority & Unread ===
   (add-to-list 'mu4e-bookmarks
 	       '(:name "All Inboxes"
home/common/desktop/mails.nix
@@ -5,6 +5,10 @@
   hostname,
   ...
 }:
+let
+  # Work hosts that sync the Red Hat (gmail) account
+  isWorkHost = hostname == "kyushu" || hostname == "aomi";
+in
 {
   accounts.email = {
     maildirBasePath = "desktop/mails";
@@ -42,7 +46,7 @@
       };
     }
     // (
-      if (hostname == "kyushu") then
+      if isWorkHost then
         {
           # Work emails
           "redhat" = {
@@ -147,7 +151,7 @@
           --maildir=$HOME/${config.accounts.email.maildirBasePath} \
           --muhome="$MUHOME" \
           --my-address=vincent@demeester.fr \
-          ${if hostname == "kyushu" then "--my-address=vdemeest@redhat.com" else ""} \
+          ${if isWorkHost then "--my-address=vdemeest@redhat.com" else ""} \
           $VERBOSE_ARG
       fi
     ''
home/common/services/goimapnotify.nix
@@ -74,6 +74,10 @@ in
           RestartSec = "30s";
           Environment = [
             "MUHOME=${config.programs.mu.home}"
+            # passage (passwordCmd) needs its store + identities; systemd user
+            # services don't inherit the shell session vars.
+            "PASSAGE_DIR=${config.xdg.dataHome}/passage"
+            "PASSAGE_IDENTITIES_FILE=${config.xdg.dataHome}/passage/identities"
           ];
         };
 
systems/aomi/home.nix
@@ -16,6 +16,8 @@ in
     ../../home/common/dev/emacs.nix
     ../../home/common/dev/containers.nix
     ../../home/common/dev/tektoncd.nix
+    ../../home/common/services/goimapnotify.nix
+    ../../home/common/services/mail-monitor.nix
     ../../home/common/desktop/passage.nix
     ../../home/common/shell/gh.nix
   ];