From 7f13edb3b8d97c8716f8f0b9bd91a0f2acf88bbf Mon Sep 17 00:00:00 2001 From: "J. Dekker" Date: Fri, 14 Jun 2024 00:49:32 +0200 Subject: [PATCH] mu: add support for setting muhome The database path can be set by the user, this is useful for keeping the Maildir and the Mu Xapian cache together without affecting XDG_CACHE_HOME Fixes #5534. Signed-off-by: J. Dekker --- modules/programs/mu.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/programs/mu.nix b/modules/programs/mu.nix index 4d051d4d..1cf86e6c 100644 --- a/modules/programs/mu.nix +++ b/modules/programs/mu.nix @@ -31,6 +31,15 @@ in { package = mkPackageOption pkgs "mu" { }; + home = mkOption { + type = with types; nullOr str; + default = null; + example = "\${config.home.homeDirectory}/Maildir/.mu"; + description = '' + Directory to store Mu's database. + ''; + }; + # No options/config file present for mu, and program author will not be # adding one soon. See https://github.com/djcb/mu/issues/882 for more # information about this. @@ -46,9 +55,13 @@ in { config = mkIf cfg.enable { home.packages = [ cfg.package ]; + home.sessionVariables = filterAttrs (n: v: v != null) { + MUHOME = cfg.home; + }; + home.activation.runMuInit = let maildirOption = genCmdMaildir config.accounts.email.maildirBasePath; - dbLocation = config.xdg.cacheHome + "/mu"; + dbLocation = if cfg.home != null then cfg.home else (config.xdg.cacheHome + "/mu"); in hm.dag.entryAfter [ "writeBoundary" ] '' # If the database directory exists, then `mu init` should NOT be run. # In theory, mu is the only thing that creates that directory, and it is @@ -56,7 +69,7 @@ in { if [[ ! -d "${dbLocation}" ]]; then run ${ getExe cfg.package - } init ${maildirOption} ${myAddresses} $VERBOSE_ARG; + } init ${maildirOption} --muhome "${dbLocation}" ${myAddresses} $VERBOSE_ARG; fi ''; };