From e21c3062694ba76e034b67b5e48c55df0538ce4a Mon Sep 17 00:00:00 2001 From: Michael Thomson Date: Tue, 8 Jul 2025 14:02:57 -0400 Subject: [PATCH] split email accounts --- modules/home-manager/emacs/emacs/init.el | 12 +- modules/home-manager/email.nix | 304 ++++++++++++----------- 2 files changed, 163 insertions(+), 153 deletions(-) diff --git a/modules/home-manager/emacs/emacs/init.el b/modules/home-manager/emacs/emacs/init.el index 9976b74..96947e0 100644 --- a/modules/home-manager/emacs/emacs/init.el +++ b/modules/home-manager/emacs/emacs/init.el @@ -672,15 +672,11 @@ :straight t :bind (("C-c m" . notmuch-hello)) :custom + (notmuch-search-oldest-first nil) (notmuch-saved-searches - '((:name "inbox (personal)" :query "tag:inbox AND tag:personal") - (:name "unread (personal)" :query "tag:unread AND tag:personal") - (:name "sent (personal)" :query "tag:sent AND tag:personal") - (:name "all mail (personal)" :query "tag:personal") - (:name "inbox (work)" :query "tag:inbox AND tag:work") - (:name "unread (work)" :query "tag:unread AND tag:work") - (:name "sent (work)" :query "tag:sent AND tag:work") - (:name "all mail (work)" :query "tag:work") + '((:name "inbox" :query "tag:inbox") + (:name "unread" :query "tag:unread") + (:name "sent" :query "tag:sent") (:name "drafts" :query "tag:draft"))) :init (add-hook 'message-send-hook (lambda () diff --git a/modules/home-manager/email.nix b/modules/home-manager/email.nix index c83d262..82d93d2 100644 --- a/modules/home-manager/email.nix +++ b/modules/home-manager/email.nix @@ -1,6 +1,7 @@ { pkgs, - config, + osConfig, + lib, ... }: { home.packages = with pkgs; [ @@ -23,21 +24,6 @@ programs = { aerc = { enable = true; - templates = { - thanks = '' - Thanks! - - {{exec "{ git remote get-url --push origin; git reflog -2 origin/master --pretty=format:%h | xargs printf '%s\n' | tac; } | xargs printf 'To %s\n %s..%s master -> master'" ""}} - ''; - }; - # extraBinds = { - # messages = { - # ga = ":flag:pipe -mb git am -3"; - # gp = ":term git push"; - # gl = ":term git log"; - # rt = ":reply -a -Tthanks"; - # }; - # }; extraConfig = { ui = { sort = "-r arrival"; @@ -50,7 +36,7 @@ unsafe-accounts-conf = true; }; compose = { - address-book-cmd = "khard email --parsable --remove-first-line %s"; + address-book-cmd = "notmuch address \"%s\""; }; filters = { "text/plain" = "colorize"; @@ -65,27 +51,6 @@ mbsync = { enable = true; }; - notmuch = { - enable = true; - new.tags = [ "new" ]; - hooks = { - postNew = '' - notmuch tag +personal "path:personal/**" - notmuch tag +work "path:work/**" - - notmuch tag +sent -new tag:new from:michael@michaelthomson.dev - notmuch tag +sent -new tag:new from:mthomson@konradgroup.com - - notmuch tag +cal attachment:.ics - - notmuch tag +inbox +unread -new "tag:new" - ''; - preNew = '' - mbsync -a - (cd ~/Maildir/work/ && gmi sync) - ''; - }; - }; lieer = { enable = true; }; @@ -103,123 +68,172 @@ }; }; - accounts = { - email = { - accounts.personal = { - primary = true; - address = "michael@michaelthomson.dev"; - realName = "Michael Thomson"; - userName = "michael@michaelthomson.dev"; - passwordCommand = "rbw get --folder email michael@michaelthomson.dev"; - aerc = { - enable = true; + programs.notmuch = lib.mkMerge [ + { + enable = true; + new.tags = [ "new" ]; + } + (lib.mkIf (osConfig.networking.hostName == "macbook") { + hooks = { + postNew = '' + notmuch tag +sent -new tag:new from:mthomson@konradgroup.com + + notmuch tag +cal attachment:.ics + + notmuch tag +inbox +unread -new "tag:new" + ''; + preNew = '' + cd ~/Maildir/work/ && gmi sync + ''; }; - mbsync = { - enable = true; - create = "both"; - expunge = "both"; + }) + (lib.mkIf (osConfig.networking.hostName != "macbook") { + hooks = { + postNew = '' + notmuch tag +sent -new tag:new from:michael@michaelthomson.dev + + notmuch tag +cal attachment:.ics + + notmuch tag +inbox +unread -new "tag:new" + ''; + preNew = '' + mbsync -a + ''; }; - imap = { - host = "mail.michaelthomson.dev"; - port = 993; - tls = { + }) + ]; + + accounts = lib.mkMerge [ + (lib.mkIf (osConfig.networking.hostName == "macbook") { + email = { + accounts.work = { + primary = true; + flavor = "gmail.com"; + address = "mthomson@konradgroup.com"; + realName = "Michael Thomson"; + aerc = { + enable = true; + # extraBinds = { + # messages = { + # md = ":modify-labels +trash"; + # }; + # }; + extraAccounts = { + source = "maildir://~/Maildir/work"; + }; + }; + notmuch = { + enable = true; + }; + lieer = { + enable = true; + settings = { + replace_slash_with_dot = true; + ignore_tags = [ "new" "personal" "work" ]; + }; + }; + }; + }; + }) + (lib.mkIf (osConfig.networking.hostName != "macbook") { + email = { + accounts.personal = { + primary = true; + address = "michael@michaelthomson.dev"; + realName = "Michael Thomson"; + userName = "michael@michaelthomson.dev"; + passwordCommand = "rbw get --folder email michael@michaelthomson.dev"; + aerc = { + enable = true; + }; + mbsync = { + enable = true; + create = "both"; + expunge = "both"; + }; + imap = { + host = "mail.michaelthomson.dev"; + port = 993; + tls = { + enable = true; + }; + }; + msmtp = { + enable = true; + }; + smtp = { + host = "mail.michaelthomson.dev"; + port = 465; + tls = { + enable = true; + }; + }; + notmuch = { + enable = true; + }; + mu = { enable = true; }; }; - msmtp = { - enable = true; - }; - smtp = { - host = "mail.michaelthomson.dev"; - port = 465; - tls = { + }; + calendar = { + basePath = ".calendar"; + accounts.personal = { + primary = true; + primaryCollection = "personal"; + remote = { + type = "caldav"; + url = "https://nextcloud.michaelthomson.dev/remote.php/dav"; + userName = "michael@michaelthomson.dev"; + passwordCommand = [ + "rbw" + "get" + "nextcloud.michaelthomson.dev" + ]; + }; + vdirsyncer = { enable = true; + auth = "basic"; + collections = ["personal"]; }; - }; - notmuch = { - enable = true; - }; - mu = { - enable = true; - }; - }; - accounts.work = { - primary = false; - flavor = "gmail.com"; - address = "mthomson@konradgroup.com"; - realName = "Michael Thomson"; - aerc = { - enable = true; - }; - notmuch = { - enable = true; - }; - lieer = { - enable = true; - settings = { - replace_slash_with_dot = true; - ignore_tags = [ "new" "personal" "work" ]; + khal = { + enable = true; + type = "calendar"; }; }; }; - }; - calendar = { - basePath = ".calendar"; - accounts.personal = { - primary = true; - primaryCollection = "personal"; - remote = { - type = "caldav"; - url = "https://nextcloud.michaelthomson.dev/remote.php/dav"; - userName = "michael@michaelthomson.dev"; - passwordCommand = [ - "rbw" - "get" - "nextcloud.michaelthomson.dev" - ]; - }; - vdirsyncer = { - enable = true; - auth = "basic"; - collections = ["personal"]; - }; - khal = { - enable = true; - type = "calendar"; + contact = { + basePath = ".contacts"; + accounts.personal = { + local = { + type = "filesystem"; + fileExt = ".vcf"; + }; + remote = { + type = "carddav"; + url = "https://nextcloud.michaelthomson.dev/remote.php/dav"; + userName = "michael@michaelthomson.dev"; + passwordCommand = [ + "rbw" + "get" + "nextcloud.michaelthomson.dev" + ]; + }; + vdirsyncer = { + enable = true; + auth = "basic"; + collections = ["contacts"]; + }; + khal = { + enable = true; + collections = ["contacts"]; + }; + khard = { + enable = true; + defaultCollection = "contacts"; + }; }; }; - }; - contact = { - basePath = ".contacts"; - accounts.personal = { - local = { - type = "filesystem"; - fileExt = ".vcf"; - }; - remote = { - type = "carddav"; - url = "https://nextcloud.michaelthomson.dev/remote.php/dav"; - userName = "michael@michaelthomson.dev"; - passwordCommand = [ - "rbw" - "get" - "nextcloud.michaelthomson.dev" - ]; - }; - vdirsyncer = { - enable = true; - auth = "basic"; - collections = ["contacts"]; - }; - khal = { - enable = true; - collections = ["contacts"]; - }; - khard = { - enable = true; - defaultCollection = "contacts"; - }; - }; - }; - }; + }) + ]; }