mirror of
https://github.com/nix-community/home-manager
synced 2024-12-24 02:39:48 +01:00
himalaya: adjust module for 0.8.X (#4093)
Added notmuch support, and adjust password commands configuration.
This commit is contained in:
parent
9a76fb9a85
commit
9ce6977fe7
8 changed files with 98 additions and 21 deletions
|
@ -11,6 +11,12 @@ let
|
|||
# make a himalaya config from a home-manager email account config
|
||||
mkAccountConfig = _: account:
|
||||
let
|
||||
imapEnabled = !isNull account.imap;
|
||||
maildirEnabled = !imapEnabled && !isNull account.maildir
|
||||
&& !account.notmuch.enable;
|
||||
notmuchEnabled = !imapEnabled && !isNull account.maildir
|
||||
&& account.notmuch.enable;
|
||||
|
||||
globalConfig = {
|
||||
email = account.address;
|
||||
display-name = account.realName;
|
||||
|
@ -31,22 +37,26 @@ let
|
|||
signature-delim = account.signature.delimiter;
|
||||
};
|
||||
|
||||
imapConfig = lib.optionalAttrs (!isNull account.imap) (compactAttrs {
|
||||
imapConfig = lib.optionalAttrs imapEnabled (compactAttrs {
|
||||
backend = "imap";
|
||||
imap-host = account.imap.host;
|
||||
imap-port = account.imap.port;
|
||||
imap-ssl = account.imap.tls.enable;
|
||||
imap-starttls = account.imap.tls.useStartTls;
|
||||
imap-login = account.userName;
|
||||
imap-passwd-cmd = builtins.concatStringsSep " " account.passwordCommand;
|
||||
imap-auth = "passwd";
|
||||
imap-passwd.cmd = builtins.concatStringsSep " " account.passwordCommand;
|
||||
});
|
||||
|
||||
maildirConfig =
|
||||
lib.optionalAttrs (isNull account.imap && !isNull account.maildir)
|
||||
(compactAttrs {
|
||||
backend = "maildir";
|
||||
maildir-root-dir = account.maildir.absPath;
|
||||
});
|
||||
maildirConfig = lib.optionalAttrs maildirEnabled (compactAttrs {
|
||||
backend = "maildir";
|
||||
maildir-root-dir = account.maildir.absPath;
|
||||
});
|
||||
|
||||
notmuchConfig = lib.optionalAttrs notmuchEnabled (compactAttrs {
|
||||
backend = "notmuch";
|
||||
notmuch-db-path = account.maildir.absPath;
|
||||
});
|
||||
|
||||
smtpConfig = lib.optionalAttrs (!isNull account.smtp) (compactAttrs {
|
||||
sender = "smtp";
|
||||
|
@ -55,14 +65,18 @@ let
|
|||
smtp-ssl = account.smtp.tls.enable;
|
||||
smtp-starttls = account.smtp.tls.useStartTls;
|
||||
smtp-login = account.userName;
|
||||
smtp-passwd-cmd = builtins.concatStringsSep " " account.passwordCommand;
|
||||
smtp-auth = "passwd";
|
||||
smtp-passwd.cmd = builtins.concatStringsSep " " account.passwordCommand;
|
||||
});
|
||||
|
||||
sendmailConfig =
|
||||
lib.optionalAttrs (isNull account.smtp) { sender = "sendmail"; };
|
||||
lib.optionalAttrs (isNull account.smtp && !isNull account.msmtp) {
|
||||
sender = "sendmail";
|
||||
sendmail-cmd = "${pkgs.msmtp}/bin/msmtp";
|
||||
};
|
||||
|
||||
config = globalConfig // signatureConfig // imapConfig // maildirConfig
|
||||
// smtpConfig // sendmailConfig;
|
||||
// notmuchConfig // smtpConfig // sendmailConfig;
|
||||
|
||||
in lib.recursiveUpdate config account.himalaya.settings;
|
||||
|
||||
|
|
|
@ -3,16 +3,16 @@ backend = "imap"
|
|||
default = true
|
||||
display-name = "H. M. Test"
|
||||
email = "hm@example.com"
|
||||
imap-auth = "passwd"
|
||||
imap-host = "imap.example.com"
|
||||
imap-login = "home.manager"
|
||||
imap-passwd-cmd = "password-command"
|
||||
imap-port = 993
|
||||
imap-ssl = true
|
||||
imap-starttls = false
|
||||
sender = "smtp"
|
||||
smtp-auth = "passwd"
|
||||
smtp-host = "smtp.example.com"
|
||||
smtp-login = "home.manager"
|
||||
smtp-passwd-cmd = "password-command"
|
||||
smtp-port = 465
|
||||
smtp-ssl = true
|
||||
smtp-starttls = false
|
||||
|
@ -22,3 +22,9 @@ drafts = "Drafts"
|
|||
inbox = "Inbox"
|
||||
sent = "Sent"
|
||||
trash = "Trash"
|
||||
|
||||
["hm@example.com".imap-passwd]
|
||||
cmd = "password-command"
|
||||
|
||||
["hm@example.com".smtp-passwd]
|
||||
cmd = "password-command"
|
||||
|
|
|
@ -10,8 +10,8 @@ with lib;
|
|||
imap.port = 993;
|
||||
smtp.port = 465;
|
||||
himalaya.enable = true;
|
||||
himalaya.backend = "deprecated";
|
||||
himalaya.sender = "deprecated";
|
||||
himalaya.backend = test.asserts.warnings.expected;
|
||||
himalaya.sender = test.asserts.warnings.expected;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
himalaya-basic = ./basic.nix;
|
||||
himalaya-imap-smtp = ./imap-smtp.nix;
|
||||
himalaya-maildir-sendmail = ./maildir-sendmail.nix;
|
||||
himalaya-notmuch-sendmail = ./notmuch-sendmail.nix;
|
||||
}
|
||||
|
|
|
@ -7,16 +7,16 @@ display-name = "H. M. Test"
|
|||
email = "hm@example.com"
|
||||
email-listing-page-size = 50
|
||||
folder-listing-page-size = 50
|
||||
imap-auth = "passwd"
|
||||
imap-host = "imap.example.com"
|
||||
imap-login = "home.manager"
|
||||
imap-passwd-cmd = "password-command"
|
||||
imap-port = 143
|
||||
imap-ssl = false
|
||||
imap-starttls = false
|
||||
sender = "smtp"
|
||||
smtp-auth = "passwd"
|
||||
smtp-host = "smtp.example.com"
|
||||
smtp-login = "home.manager"
|
||||
smtp-passwd-cmd = "password-command"
|
||||
smtp-port = 465
|
||||
smtp-ssl = true
|
||||
smtp-starttls = true
|
||||
|
@ -27,3 +27,9 @@ drafts = "D"
|
|||
inbox = "In2"
|
||||
sent = "Out"
|
||||
trash = "Trash"
|
||||
|
||||
["hm@example.com".imap-passwd]
|
||||
cmd = "password-command"
|
||||
|
||||
["hm@example.com".smtp-passwd]
|
||||
cmd = "password-command"
|
||||
|
|
|
@ -11,12 +11,10 @@ with lib;
|
|||
realName = "H. M. Test";
|
||||
passwordCommand = "password-command";
|
||||
folders = { trash = "Deleted"; };
|
||||
msmtp.enable = true;
|
||||
himalaya = {
|
||||
enable = true;
|
||||
settings = {
|
||||
sender = "sendmail";
|
||||
sendmail-cmd = "msmtp";
|
||||
};
|
||||
settings = { sendmail-cmd = "msmtp"; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
email-listing-page-size = 50
|
||||
|
||||
["hm@example.com"]
|
||||
backend = "notmuch"
|
||||
default = true
|
||||
display-name = "H. M. Test"
|
||||
email = "hm@example.com"
|
||||
notmuch-db-path = "/home/hm-user/Maildir/hm@example.com"
|
||||
sender = "sendmail"
|
||||
sendmail-cmd = "msmtp"
|
||||
|
||||
["hm@example.com".folder-aliases]
|
||||
drafts = "Drafts"
|
||||
inbox = "Inbox"
|
||||
sent = "Sent"
|
||||
trash = "Deleted"
|
36
tests/modules/programs/himalaya/notmuch-sendmail.nix
Normal file
36
tests/modules/programs/himalaya/notmuch-sendmail.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
accounts.email.accounts = {
|
||||
"hm@example.com" = {
|
||||
primary = true;
|
||||
address = "hm@example.com";
|
||||
userName = "home.manager";
|
||||
realName = "H. M. Test";
|
||||
passwordCommand = "password-command";
|
||||
folders = { trash = "Deleted"; };
|
||||
notmuch.enable = true;
|
||||
msmtp.enable = true;
|
||||
himalaya = {
|
||||
enable = true;
|
||||
settings = { sendmail-cmd = "msmtp"; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
programs.himalaya = {
|
||||
enable = true;
|
||||
settings = { email-listing-page-size = 50; };
|
||||
};
|
||||
|
||||
test.stubs.himalaya = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/himalaya/config.toml
|
||||
assertFileContent home-files/.config/himalaya/config.toml ${
|
||||
./notmuch-sendmail-expected.toml
|
||||
}
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue