mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +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
|
# make a himalaya config from a home-manager email account config
|
||||||
mkAccountConfig = _: account:
|
mkAccountConfig = _: account:
|
||||||
let
|
let
|
||||||
|
imapEnabled = !isNull account.imap;
|
||||||
|
maildirEnabled = !imapEnabled && !isNull account.maildir
|
||||||
|
&& !account.notmuch.enable;
|
||||||
|
notmuchEnabled = !imapEnabled && !isNull account.maildir
|
||||||
|
&& account.notmuch.enable;
|
||||||
|
|
||||||
globalConfig = {
|
globalConfig = {
|
||||||
email = account.address;
|
email = account.address;
|
||||||
display-name = account.realName;
|
display-name = account.realName;
|
||||||
|
@ -31,22 +37,26 @@ let
|
||||||
signature-delim = account.signature.delimiter;
|
signature-delim = account.signature.delimiter;
|
||||||
};
|
};
|
||||||
|
|
||||||
imapConfig = lib.optionalAttrs (!isNull account.imap) (compactAttrs {
|
imapConfig = lib.optionalAttrs imapEnabled (compactAttrs {
|
||||||
backend = "imap";
|
backend = "imap";
|
||||||
imap-host = account.imap.host;
|
imap-host = account.imap.host;
|
||||||
imap-port = account.imap.port;
|
imap-port = account.imap.port;
|
||||||
imap-ssl = account.imap.tls.enable;
|
imap-ssl = account.imap.tls.enable;
|
||||||
imap-starttls = account.imap.tls.useStartTls;
|
imap-starttls = account.imap.tls.useStartTls;
|
||||||
imap-login = account.userName;
|
imap-login = account.userName;
|
||||||
imap-passwd-cmd = builtins.concatStringsSep " " account.passwordCommand;
|
imap-auth = "passwd";
|
||||||
|
imap-passwd.cmd = builtins.concatStringsSep " " account.passwordCommand;
|
||||||
});
|
});
|
||||||
|
|
||||||
maildirConfig =
|
maildirConfig = lib.optionalAttrs maildirEnabled (compactAttrs {
|
||||||
lib.optionalAttrs (isNull account.imap && !isNull account.maildir)
|
backend = "maildir";
|
||||||
(compactAttrs {
|
maildir-root-dir = account.maildir.absPath;
|
||||||
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 {
|
smtpConfig = lib.optionalAttrs (!isNull account.smtp) (compactAttrs {
|
||||||
sender = "smtp";
|
sender = "smtp";
|
||||||
|
@ -55,14 +65,18 @@ let
|
||||||
smtp-ssl = account.smtp.tls.enable;
|
smtp-ssl = account.smtp.tls.enable;
|
||||||
smtp-starttls = account.smtp.tls.useStartTls;
|
smtp-starttls = account.smtp.tls.useStartTls;
|
||||||
smtp-login = account.userName;
|
smtp-login = account.userName;
|
||||||
smtp-passwd-cmd = builtins.concatStringsSep " " account.passwordCommand;
|
smtp-auth = "passwd";
|
||||||
|
smtp-passwd.cmd = builtins.concatStringsSep " " account.passwordCommand;
|
||||||
});
|
});
|
||||||
|
|
||||||
sendmailConfig =
|
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
|
config = globalConfig // signatureConfig // imapConfig // maildirConfig
|
||||||
// smtpConfig // sendmailConfig;
|
// notmuchConfig // smtpConfig // sendmailConfig;
|
||||||
|
|
||||||
in lib.recursiveUpdate config account.himalaya.settings;
|
in lib.recursiveUpdate config account.himalaya.settings;
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,16 @@ backend = "imap"
|
||||||
default = true
|
default = true
|
||||||
display-name = "H. M. Test"
|
display-name = "H. M. Test"
|
||||||
email = "hm@example.com"
|
email = "hm@example.com"
|
||||||
|
imap-auth = "passwd"
|
||||||
imap-host = "imap.example.com"
|
imap-host = "imap.example.com"
|
||||||
imap-login = "home.manager"
|
imap-login = "home.manager"
|
||||||
imap-passwd-cmd = "password-command"
|
|
||||||
imap-port = 993
|
imap-port = 993
|
||||||
imap-ssl = true
|
imap-ssl = true
|
||||||
imap-starttls = false
|
imap-starttls = false
|
||||||
sender = "smtp"
|
sender = "smtp"
|
||||||
|
smtp-auth = "passwd"
|
||||||
smtp-host = "smtp.example.com"
|
smtp-host = "smtp.example.com"
|
||||||
smtp-login = "home.manager"
|
smtp-login = "home.manager"
|
||||||
smtp-passwd-cmd = "password-command"
|
|
||||||
smtp-port = 465
|
smtp-port = 465
|
||||||
smtp-ssl = true
|
smtp-ssl = true
|
||||||
smtp-starttls = false
|
smtp-starttls = false
|
||||||
|
@ -22,3 +22,9 @@ drafts = "Drafts"
|
||||||
inbox = "Inbox"
|
inbox = "Inbox"
|
||||||
sent = "Sent"
|
sent = "Sent"
|
||||||
trash = "Trash"
|
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;
|
imap.port = 993;
|
||||||
smtp.port = 465;
|
smtp.port = 465;
|
||||||
himalaya.enable = true;
|
himalaya.enable = true;
|
||||||
himalaya.backend = "deprecated";
|
himalaya.backend = test.asserts.warnings.expected;
|
||||||
himalaya.sender = "deprecated";
|
himalaya.sender = test.asserts.warnings.expected;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,5 @@
|
||||||
himalaya-basic = ./basic.nix;
|
himalaya-basic = ./basic.nix;
|
||||||
himalaya-imap-smtp = ./imap-smtp.nix;
|
himalaya-imap-smtp = ./imap-smtp.nix;
|
||||||
himalaya-maildir-sendmail = ./maildir-sendmail.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 = "hm@example.com"
|
||||||
email-listing-page-size = 50
|
email-listing-page-size = 50
|
||||||
folder-listing-page-size = 50
|
folder-listing-page-size = 50
|
||||||
|
imap-auth = "passwd"
|
||||||
imap-host = "imap.example.com"
|
imap-host = "imap.example.com"
|
||||||
imap-login = "home.manager"
|
imap-login = "home.manager"
|
||||||
imap-passwd-cmd = "password-command"
|
|
||||||
imap-port = 143
|
imap-port = 143
|
||||||
imap-ssl = false
|
imap-ssl = false
|
||||||
imap-starttls = false
|
imap-starttls = false
|
||||||
sender = "smtp"
|
sender = "smtp"
|
||||||
|
smtp-auth = "passwd"
|
||||||
smtp-host = "smtp.example.com"
|
smtp-host = "smtp.example.com"
|
||||||
smtp-login = "home.manager"
|
smtp-login = "home.manager"
|
||||||
smtp-passwd-cmd = "password-command"
|
|
||||||
smtp-port = 465
|
smtp-port = 465
|
||||||
smtp-ssl = true
|
smtp-ssl = true
|
||||||
smtp-starttls = true
|
smtp-starttls = true
|
||||||
|
@ -27,3 +27,9 @@ drafts = "D"
|
||||||
inbox = "In2"
|
inbox = "In2"
|
||||||
sent = "Out"
|
sent = "Out"
|
||||||
trash = "Trash"
|
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";
|
realName = "H. M. Test";
|
||||||
passwordCommand = "password-command";
|
passwordCommand = "password-command";
|
||||||
folders = { trash = "Deleted"; };
|
folders = { trash = "Deleted"; };
|
||||||
|
msmtp.enable = true;
|
||||||
himalaya = {
|
himalaya = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = { sendmail-cmd = "msmtp"; };
|
||||||
sender = "sendmail";
|
|
||||||
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