mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 15:14:26 +00:00
himalaya: fix notmuch backend
Previously, IMAP was preferred over notmuch, even if notmuch was configured, causing problems with setting account flavor (which automatically sets IMAP settings). The new backend order is: notmuch > IMAP > maildir This also fixes the notmuch DB path being set to the wrong location. The notmuch DB is located at the maildir base path, not in each account's maildir.
This commit is contained in:
parent
98282a481d
commit
24805d3ca7
2 changed files with 11 additions and 7 deletions
|
@ -8,14 +8,18 @@ let
|
||||||
# attrs util that removes entries containing a null value
|
# attrs util that removes entries containing a null value
|
||||||
compactAttrs = lib.filterAttrs (_: val: !isNull val);
|
compactAttrs = lib.filterAttrs (_: val: !isNull val);
|
||||||
|
|
||||||
|
# Needed for notmuch config, because the DB is here, and not in each account's dir
|
||||||
|
maildirBasePath = config.accounts.email.maildirBasePath;
|
||||||
|
|
||||||
# make a himalaya config from a home-manager email account config
|
# make a himalaya config from a home-manager email account config
|
||||||
mkAccountConfig = _: account:
|
mkAccountConfig = _: account:
|
||||||
let
|
let
|
||||||
imapEnabled = !isNull account.imap;
|
# Use notmuch if it's enabled, otherwise fallback to IMAP then maildir
|
||||||
maildirEnabled = !imapEnabled && !isNull account.maildir
|
# Maildir is always set, so there's no easy way to detect if it's being used
|
||||||
&& !account.notmuch.enable;
|
notmuchEnabled = account.notmuch.enable;
|
||||||
notmuchEnabled = !imapEnabled && !isNull account.maildir
|
imapEnabled = !isNull account.imap && !notmuchEnabled;
|
||||||
&& account.notmuch.enable;
|
maildirEnabled = !isNull account.maildir && !imapEnabled
|
||||||
|
&& !notmuchEnabled;
|
||||||
|
|
||||||
globalConfig = {
|
globalConfig = {
|
||||||
email = account.address;
|
email = account.address;
|
||||||
|
@ -55,7 +59,7 @@ let
|
||||||
|
|
||||||
notmuchConfig = lib.optionalAttrs notmuchEnabled (compactAttrs {
|
notmuchConfig = lib.optionalAttrs notmuchEnabled (compactAttrs {
|
||||||
backend = "notmuch";
|
backend = "notmuch";
|
||||||
notmuch-db-path = account.maildir.absPath;
|
notmuch-db-path = maildirBasePath;
|
||||||
});
|
});
|
||||||
|
|
||||||
smtpConfig = lib.optionalAttrs (!isNull account.smtp) (compactAttrs {
|
smtpConfig = lib.optionalAttrs (!isNull account.smtp) (compactAttrs {
|
||||||
|
|
|
@ -5,7 +5,7 @@ backend = "notmuch"
|
||||||
default = true
|
default = true
|
||||||
display-name = "H. M. Test"
|
display-name = "H. M. Test"
|
||||||
email = "hm@example.com"
|
email = "hm@example.com"
|
||||||
notmuch-db-path = "/home/hm-user/Maildir/hm@example.com"
|
notmuch-db-path = "/home/hm-user/Maildir"
|
||||||
sender = "sendmail"
|
sender = "sendmail"
|
||||||
sendmail-cmd = "msmtp"
|
sendmail-cmd = "msmtp"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue