mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
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 <jdek@itanimul.li>
This commit is contained in:
parent
8d5e27b480
commit
7f13edb3b8
1 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue