himalaya: 0.6.x config updates

Some properties were renamed. Big changes however include `backend` and
`sender` enum options.
This commit is contained in:
toastal 2022-10-16 15:25:31 +07:00 committed by Robert Helgesson
parent 05d71f517b
commit 9fb1bb9794
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
3 changed files with 51 additions and 15 deletions

View File

@ -11,7 +11,7 @@ let
toHimalayaConfig = account:
{
email = account.address;
name = account.realName;
display-name = account.realName;
default = account.primary;
mailboxes = {
@ -20,30 +20,46 @@ let
draft = account.folders.drafts;
# NOTE: himalaya does not support configuring the name of the trash folder
};
} // (lib.optionalAttrs (account.signature.showSignature == "append") {
# FIXME: signature cannot be attached
signature = account.signature.text;
signature-delim = account.signature.delimiter;
}) // (if account.himalaya.backend == null then {
backend = "none";
} else if account.himalaya.backend == "imap" then {
# FIXME: does not support disabling TLS altogether
# NOTE: does not accept sequence of strings for password commands
backend = account.himalaya.backend;
imap-login = account.userName;
imap-passwd-cmd = lib.escapeShellArgs account.passwordCommand;
imap-host = account.imap.host;
imap-port = account.imap.port;
imap-starttls = account.imap.tls.useStartTls;
} else if account.himalaya.backend == "maildir" then {
backend = account.himalaya.backend;
maildir-root-dir = account.maildirBasePath;
} else
throw "Unsupported backend: ${account.himalaya.backend}")
// (if account.himalaya.sender == null then {
sender = "none";
} else if account.himalaya.sender == "smtp" then {
sender = account.himalaya.sender;
smtp-login = account.userName;
smtp-passwd-cmd = lib.escapeShellArgs account.passwordCommand;
smtp-host = account.smtp.host;
smtp-port = account.smtp.port;
smtp-starttls = account.smtp.tls.useStartTls;
} // (lib.optionalAttrs (account.signature.showSignature == "append") {
# FIXME: signature cannot be attached
signature = account.signature.text;
}) // account.himalaya.settings;
} else if account.himalaya.sender == "sendmail" then {
sender = account.himalaya.sender;
} else
throw "Unsupported sender: ${account.himalaya.sender}")
// account.himalaya.settings;
in {
# NOTE: will not start without this configured, but each account overrides it
name = "";
display-name = "";
} // cfg.settings // (lib.mapAttrs (_: toHimalayaConfig) enabledAccounts);
in {
meta.maintainers = with lib.hm.maintainers; [ ambroisie ];
meta.maintainers = with lib.hm.maintainers; [ toastal ];
options = with lib; {
programs.himalaya = {
@ -63,7 +79,8 @@ in {
default = { };
example = lib.literalExpression ''
{
default-page-size = 50;
email-listing-page-size = 50;
watch-cmds = [ "mbsync -a" ]
}
'';
description = ''
@ -80,6 +97,22 @@ in {
the himalaya mail client for this account
'';
backend = mkOption {
# TODO: “notmuch” (requires compile flag for himalaya, libnotmuch)
type = types.nullOr (types.enum [ "imap" "maildir" ]);
description = ''
The method for which <command>himalaya</command> will fetch, store,
etc. mail.
'';
};
sender = mkOption {
type = types.nullOr (types.enum [ "smtp" "sendmail" ]);
description = ''
The method for which <command>himalaya</command> will send mail.
'';
};
settings = mkOption {
type = tomlFormat.type;
default = { };

View File

@ -1,16 +1,18 @@
display-name = ""
downloads-dir = "/data/download"
name = ""
["hm@example.com"]
backend = "imap"
default = true
default-page-size = 50
display-name = "H. M. Test"
email = "hm@example.com"
email-listing-page-size = 50
imap-host = "imap.example.com"
imap-login = "home.manager"
imap-passwd-cmd = "'password-command'"
imap-port = 995
imap-starttls = false
name = "H. M. Test"
sender = "smtp"
smtp-host = "smtp.example.com"
smtp-login = "home.manager"
smtp-passwd-cmd = "'password-command'"

View File

@ -10,7 +10,9 @@ with lib;
himalaya = {
enable = true;
settings = { default-page-size = 50; };
backend = "imap";
sender = "smtp";
settings = { email-listing-page-size = 50; };
};
folders = {
@ -38,4 +40,3 @@ with lib;
}
'';
}