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

View file

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