feat(email): add mu indexer

This commit is contained in:
Ray Andrew 2025-12-26 02:07:35 -06:00
parent 9d13f9cd14
commit eb73545d64
Signed by: rayandrew
SSH key fingerprint: SHA256:XYrYrxF0Z3A72n8P/p6mqPRNQZT22F88XcLsG+kX4xw
2 changed files with 31 additions and 7 deletions

View file

@ -3,6 +3,7 @@
lib,
config,
dots,
home-dir,
xdg-config-dir,
...
}:
@ -14,6 +15,7 @@
mbsync = mkEnableOption "Enable Mbsync";
neomutt = mkEnableOption "Enable NeoMutt";
notmuch = mkEnableOption "Enable notmuch";
mu = mkEnableOption "Enable mu (maildir-utils)";
mailcap = mkEnableOption "Enable mailcap";
};
@ -33,8 +35,26 @@
enable = config.custom.email.mbsync;
configFile = "${dots}/config/mbsync/mbsyncrc";
frequency = "*:0/3";
extraPackages = with pkgs; [ sops ] ++ lib.optionals config.custom.email.notmuch [ notmuch ];
postExec = lib.mkIf config.custom.email.notmuch "${pkgs.notmuch}/bin/notmuch new";
extraPackages =
with pkgs;
[ sops ]
++ lib.optionals config.custom.email.notmuch [ notmuch ]
++ lib.optionals config.custom.email.mu [ mu ];
postExec =
let
notmuchCmd = lib.optionalString config.custom.email.notmuch "${pkgs.notmuch}/bin/notmuch new";
muCmd = lib.optionalString config.custom.email.mu ''
# Initialize mu if not already done
if [ ! -d "${home-dir}/.cache/mu" ] && [ ! -d "${home-dir}/.mu" ]; then
${pkgs.mu}/bin/mu init --maildir=${home-dir}/mail
fi
${pkgs.mu}/bin/mu index
'';
in
lib.mkIf (config.custom.email.notmuch || config.custom.email.mu) ''
${notmuchCmd}
${muCmd}
'';
environment = {
SOPS_AGE_KEY_FILE = "${xdg-config-dir}/sops/age/keys.txt";
}
@ -61,6 +81,9 @@
++ lib.optionals config.custom.email.notmuch [
notmuch
]
++ lib.optionals config.custom.email.mu [
mu
]
++ lib.optionals config.custom.email.mailcap [
mailcap
w3m # HTML rendering
@ -88,11 +111,11 @@
# Create mail directories
home.activation.createMailDirs = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
mkdir -p ~/mail/personal/Inbox
mkdir -p ~/mail/uchicago/Inbox
mkdir -p ~/.cache/neomutt/headers
mkdir -p ~/.cache/neomutt/messages
mkdir -p ~/.local/state
mkdir -p ${home-dir}/mail/personal/Inbox
mkdir -p ${home-dir}/mail/uchicago/Inbox
mkdir -p ${home-dir}/.cache/neomutt/headers
mkdir -p ${home-dir}/.cache/neomutt/messages
mkdir -p ${home-dir}/.local/state
'';
# Set NOTMUCH_CONFIG environment variable

View file

@ -111,6 +111,7 @@
mbsync = true;
mailcap = true;
notmuch = true;
mu = true;
};
};
}