mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
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);
|
template = fromJSON (readFile ./astroid-config-template.json);
|
||||||
astroidConfig = foldl' recursiveUpdate template [
|
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;
|
accounts = mapAttrs (n: accountAttr) astroidAccounts;
|
||||||
crypto.gpg.path = "${pkgs.gnupg}/bin/gpg";
|
crypto.gpg.path = "${pkgs.gnupg}/bin/gpg";
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,29 +167,29 @@ in {
|
||||||
home.packages = [ pkgs.notmuch ];
|
home.packages = [ pkgs.notmuch ];
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
NOTMUCH_CONFIG = "${config.xdg.configHome}/notmuch/notmuchrc";
|
NOTMUCH_CONFIG = "${config.xdg.configHome}/notmuch/default/config";
|
||||||
NMBGIT = "${config.xdg.dataHome}/notmuch/nmbug";
|
NMBGIT = "${config.xdg.dataHome}/notmuch/nmbug";
|
||||||
};
|
};
|
||||||
|
|
||||||
xdg.configFile."notmuch/notmuchrc".text =
|
xdg.configFile = let
|
||||||
let toIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
|
|
||||||
in ''
|
|
||||||
# Generated by Home Manager.
|
|
||||||
|
|
||||||
'' + toIni notmuchIni;
|
|
||||||
|
|
||||||
home.file = let
|
|
||||||
hook = name: cmds: {
|
hook = name: cmds: {
|
||||||
"${notmuchIni.database.path}/.notmuch/hooks/${name}".source =
|
"notmuch/default/hooks/${name}".source = pkgs.writeShellScript name ''
|
||||||
pkgs.writeShellScript name ''
|
export PATH="${pkgs.notmuch}/bin''${PATH:+:}$PATH"
|
||||||
export PATH="${pkgs.notmuch}/bin''${PATH:+:}$PATH"
|
export NOTMUCH_CONFIG="${config.xdg.configHome}/notmuch/default/config"
|
||||||
export NOTMUCH_CONFIG="${config.xdg.configHome}/notmuch/notmuchrc"
|
export NMBGIT="${config.xdg.dataHome}/notmuch/nmbug"
|
||||||
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 != "")
|
// optionalAttrs (cfg.hooks.postNew != "")
|
||||||
(hook "post-new" cfg.hooks.postNew)
|
(hook "post-new" cfg.hooks.postNew)
|
||||||
// optionalAttrs (cfg.hooks.postInsert != "")
|
// optionalAttrs (cfg.hooks.postInsert != "")
|
||||||
|
|
|
@ -27,7 +27,7 @@ let
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
} // optionalAttrs account.notmuch.enable {
|
} // optionalAttrs account.notmuch.enable {
|
||||||
Environment =
|
Environment =
|
||||||
"NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc";
|
"NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/default/config";
|
||||||
};
|
};
|
||||||
|
|
||||||
Install = { WantedBy = [ "default.target" ]; };
|
Install = { WantedBy = [ "default.target" ]; };
|
||||||
|
|
|
@ -27,7 +27,7 @@ let
|
||||||
ExecStart = "${config.programs.lieer.package}/bin/gmi sync";
|
ExecStart = "${config.programs.lieer.package}/bin/gmi sync";
|
||||||
WorkingDirectory = account.maildir.absPath;
|
WorkingDirectory = account.maildir.absPath;
|
||||||
Environment =
|
Environment =
|
||||||
"NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/notmuchrc";
|
"NOTMUCH_CONFIG=${config.xdg.configHome}/notmuch/default/config";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[Service]
|
[Service]
|
||||||
Environment=NOTMUCH_CONFIG=/home/hm-user/.config/notmuch/notmuchrc
|
Environment=NOTMUCH_CONFIG=/home/hm-user/.config/notmuch/default/config
|
||||||
ExecStart=@gmailieer@/bin/gmi sync
|
ExecStart=@gmailieer@/bin/gmi sync
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
WorkingDirectory=/home/hm-user/Mail/hm@example.com
|
WorkingDirectory=/home/hm-user/Mail/hm@example.com
|
||||||
|
|
Loading…
Reference in a new issue