notmuch: fix database creation when using hooks
When an hook is defined, a side effect was the creation of the
${notmuchIni.database.path}/.notmuch/ directory by home-manager. If
the Xapian database does not exist yet but this .notmuch directory
exists, Notmuch is confused and throws an error when `notmuch new` is
run (while this should create the database the first time).
This commit changes the hooks paths to $XDG_CONFIG_HOME where Notmuch
expects them (see notmuch-config(1)) instead of inside the maildir
database directory.
It also moves the configuration where Notmuch expects it, but the
$NOTMUCH_CONFIG environment variable is kept for backward
compatibility.
This commit is contained in:
parent
85bbc6cc12
commit
6d9d9294d0
5 changed files with 22 additions and 21 deletions
|
|
@ -42,7 +42,8 @@ let
|
|||
template = fromJSON (readFile ./astroid-config-template.json);
|
||||
astroidConfig = foldl' recursiveUpdate template [
|
||||
{
|
||||
astroid.notmuch_config = "${config.xdg.configHome}/notmuch/notmuchrc";
|
||||
astroid.notmuch_config =
|
||||
"${config.xdg.configHome}/notmuch/default/config";
|
||||
accounts = mapAttrs (n: accountAttr) astroidAccounts;
|
||||
crypto.gpg.path = "${pkgs.gnupg}/bin/gpg";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,29 +167,29 @@ in {
|
|||
home.packages = [ pkgs.notmuch ];
|
||||
|
||||
home.sessionVariables = {
|
||||
NOTMUCH_CONFIG = "${config.xdg.configHome}/notmuch/notmuchrc";
|
||||
NOTMUCH_CONFIG = "${config.xdg.configHome}/notmuch/default/config";
|
||||
NMBGIT = "${config.xdg.dataHome}/notmuch/nmbug";
|
||||
};
|
||||
|
||||
xdg.configFile."notmuch/notmuchrc".text =
|
||||
let toIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
|
||||
in ''
|
||||
# Generated by Home Manager.
|
||||
|
||||
'' + toIni notmuchIni;
|
||||
|
||||
home.file = let
|
||||
xdg.configFile = let
|
||||
hook = name: cmds: {
|
||||
"${notmuchIni.database.path}/.notmuch/hooks/${name}".source =
|
||||
pkgs.writeShellScript name ''
|
||||
export PATH="${pkgs.notmuch}/bin''${PATH:+:}$PATH"
|
||||
export NOTMUCH_CONFIG="${config.xdg.configHome}/notmuch/notmuchrc"
|
||||
export NMBGIT="${config.xdg.dataHome}/notmuch/nmbug"
|
||||
"notmuch/default/hooks/${name}".source = pkgs.writeShellScript name ''
|
||||
export PATH="${pkgs.notmuch}/bin''${PATH:+:}$PATH"
|
||||
export NOTMUCH_CONFIG="${config.xdg.configHome}/notmuch/default/config"
|
||||
export NMBGIT="${config.xdg.dataHome}/notmuch/nmbug"
|
||||
|
||||
${cmds}
|
||||
'';
|
||||
${cmds}
|
||||
'';
|
||||
};
|
||||
in optionalAttrs (cfg.hooks.preNew != "") (hook "pre-new" cfg.hooks.preNew)
|
||||
in {
|
||||
"notmuch/default/config".text =
|
||||
let toIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
|
||||
in ''
|
||||
# Generated by Home Manager.
|
||||
|
||||
'' + toIni notmuchIni;
|
||||
}
|
||||
// optionalAttrs (cfg.hooks.preNew != "") (hook "pre-new" cfg.hooks.preNew)
|
||||
// optionalAttrs (cfg.hooks.postNew != "")
|
||||
(hook "post-new" cfg.hooks.postNew)
|
||||
// optionalAttrs (cfg.hooks.postInsert != "")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue