1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-15 23:59:45 +01:00

himalaya: 0.6.x config updates

Some properties were renamed. Big changes however include `backend` and
`sender` enum options.

(cherry picked from commit 9fb1bb9794)
This commit is contained in:
toastal 2022-10-16 15:25:31 +07:00 committed by Robert Helgesson
parent c4c5ef1fa8
commit 3bf287ef12
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: toHimalayaConfig = account:
{ {
email = account.address; email = account.address;
name = account.realName; display-name = account.realName;
default = account.primary; default = account.primary;
mailboxes = { mailboxes = {
@ -20,30 +20,46 @@ let
draft = account.folders.drafts; draft = account.folders.drafts;
# NOTE: himalaya does not support configuring the name of the trash folder # 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 # FIXME: does not support disabling TLS altogether
# NOTE: does not accept sequence of strings for password commands # NOTE: does not accept sequence of strings for password commands
backend = account.himalaya.backend;
imap-login = account.userName; imap-login = account.userName;
imap-passwd-cmd = lib.escapeShellArgs account.passwordCommand; imap-passwd-cmd = lib.escapeShellArgs account.passwordCommand;
imap-host = account.imap.host; imap-host = account.imap.host;
imap-port = account.imap.port; imap-port = account.imap.port;
imap-starttls = account.imap.tls.useStartTls; 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-login = account.userName;
smtp-passwd-cmd = lib.escapeShellArgs account.passwordCommand; smtp-passwd-cmd = lib.escapeShellArgs account.passwordCommand;
smtp-host = account.smtp.host; smtp-host = account.smtp.host;
smtp-port = account.smtp.port; smtp-port = account.smtp.port;
smtp-starttls = account.smtp.tls.useStartTls; smtp-starttls = account.smtp.tls.useStartTls;
} // (lib.optionalAttrs (account.signature.showSignature == "append") { } else if account.himalaya.sender == "sendmail" then {
# FIXME: signature cannot be attached sender = account.himalaya.sender;
signature = account.signature.text; } else
}) // account.himalaya.settings; throw "Unsupported sender: ${account.himalaya.sender}")
// account.himalaya.settings;
in { in {
# NOTE: will not start without this configured, but each account overrides it # NOTE: will not start without this configured, but each account overrides it
name = ""; display-name = "";
} // cfg.settings // (lib.mapAttrs (_: toHimalayaConfig) enabledAccounts); } // cfg.settings // (lib.mapAttrs (_: toHimalayaConfig) enabledAccounts);
in { in {
meta.maintainers = with lib.hm.maintainers; [ ambroisie ]; meta.maintainers = with lib.hm.maintainers; [ toastal ];
options = with lib; { options = with lib; {
programs.himalaya = { programs.himalaya = {
@ -63,7 +79,8 @@ in {
default = { }; default = { };
example = lib.literalExpression '' example = lib.literalExpression ''
{ {
default-page-size = 50; email-listing-page-size = 50;
watch-cmds = [ "mbsync -a" ]
} }
''; '';
description = '' description = ''
@ -80,6 +97,22 @@ in {
the himalaya mail client for this account 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 { settings = mkOption {
type = tomlFormat.type; type = tomlFormat.type;
default = { }; default = { };

View file

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

View file

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