Replace notmuch with mu4e for email
mu4e's refile moves messages between IMAP folders, enabling cross-device sync via mbsync. notmuch tags are local-only. - Switch from notmuch to mu/mu4e packages - Auto-initialize mu database on first sync - Configure mu4e with folder shortcuts and refile to Archive - Add NixOS load-path for mu4e elisp files
This commit is contained in:
@@ -7,14 +7,15 @@ let
|
||||
in
|
||||
{
|
||||
options.home.roles.email = {
|
||||
enable = mkEnableOption "Enable email with notmuch, mbsync, and msmtp";
|
||||
enable = mkEnableOption "Enable email with mu4e, mbsync, and msmtp";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = with pkgs; [
|
||||
isync # provides mbsync for IMAP sync
|
||||
msmtp # for SMTP sending
|
||||
notmuch # email indexing and search
|
||||
mu # email indexer for mu4e
|
||||
mu.mu4e # mu4e elisp files for Emacs
|
||||
openssl # for certificate management
|
||||
];
|
||||
|
||||
@@ -52,58 +53,6 @@ in
|
||||
SyncState *
|
||||
'';
|
||||
|
||||
# Notmuch configuration
|
||||
home.file.".notmuch-config".text = ''
|
||||
[database]
|
||||
path=${config.home.homeDirectory}/Mail
|
||||
|
||||
[user]
|
||||
name=John Ogle
|
||||
primary_email=john@ogle.fyi
|
||||
|
||||
[new]
|
||||
tags=unread;new;
|
||||
ignore=
|
||||
|
||||
[search]
|
||||
exclude_tags=deleted;spam;
|
||||
|
||||
[maildir]
|
||||
synchronize_flags=true
|
||||
'';
|
||||
|
||||
# Notmuch post-new hook for folder-based tagging
|
||||
home.file."Mail/.notmuch/hooks/post-new" = {
|
||||
executable = true;
|
||||
text = ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
# Tag messages based on their maildir folder location
|
||||
# This runs after 'notmuch new' indexes new messages
|
||||
|
||||
# Process only messages with the 'new' tag (just indexed)
|
||||
# Add inbox tag only for messages in INBOX folder
|
||||
${pkgs.notmuch}/bin/notmuch tag +inbox -- tag:new AND folder:INBOX
|
||||
|
||||
# Add sent tag for messages in Sent folder
|
||||
${pkgs.notmuch}/bin/notmuch tag +sent -inbox -- tag:new AND folder:Sent
|
||||
|
||||
# Add draft tag for messages in Drafts folder
|
||||
${pkgs.notmuch}/bin/notmuch tag +draft -inbox -- tag:new AND folder:Drafts
|
||||
|
||||
# Add spam tag for messages in Spam folder
|
||||
${pkgs.notmuch}/bin/notmuch tag +spam -inbox -unread -- tag:new AND folder:Spam
|
||||
|
||||
# Add deleted tag for messages in Trash folder
|
||||
${pkgs.notmuch}/bin/notmuch tag +deleted -inbox -unread -- tag:new AND folder:Trash
|
||||
|
||||
# Add archive tag for messages in Archive folder
|
||||
${pkgs.notmuch}/bin/notmuch tag +archive -inbox -- tag:new AND folder:Archive
|
||||
|
||||
# Remove the temporary 'new' tag from all messages
|
||||
${pkgs.notmuch}/bin/notmuch tag -new -- tag:new
|
||||
'';
|
||||
};
|
||||
|
||||
# msmtp configuration
|
||||
home.file.".msmtprc".text = ''
|
||||
# Default settings
|
||||
@@ -135,7 +84,7 @@ in
|
||||
};
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart = "${pkgs.bash}/bin/bash -c '${pkgs.isync}/bin/mbsync -a && ${pkgs.notmuch}/bin/notmuch new'";
|
||||
ExecStart = "${pkgs.bash}/bin/bash -c '${pkgs.isync}/bin/mbsync -a && (${pkgs.mu}/bin/mu info >/dev/null 2>&1 || ${pkgs.mu}/bin/mu init --maildir ~/Mail) && ${pkgs.mu}/bin/mu index'";
|
||||
Environment = "PATH=${pkgs.rbw}/bin:${pkgs.coreutils}/bin";
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
|
||||
Reference in New Issue
Block a user