From 9fb1bb9794d85c80126e1840a836280f9c83ee71 Mon Sep 17 00:00:00 2001 From: toastal Date: Sun, 16 Oct 2022 15:25:31 +0700 Subject: [PATCH] himalaya: 0.6.x config updates Some properties were renamed. Big changes however include `backend` and `sender` enum options. --- modules/programs/himalaya.nix | 53 +++++++++++++++---- .../programs/himalaya/himalaya-expected.toml | 8 +-- tests/modules/programs/himalaya/himalaya.nix | 5 +- 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/modules/programs/himalaya.nix b/modules/programs/himalaya.nix index 1faee8202..92328153f 100644 --- a/modules/programs/himalaya.nix +++ b/modules/programs/himalaya.nix @@ -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 himalaya will fetch, store, + etc. mail. + ''; + }; + + sender = mkOption { + type = types.nullOr (types.enum [ "smtp" "sendmail" ]); + description = '' + The method for which himalaya will send mail. + ''; + }; + settings = mkOption { type = tomlFormat.type; default = { }; diff --git a/tests/modules/programs/himalaya/himalaya-expected.toml b/tests/modules/programs/himalaya/himalaya-expected.toml index 6c2dfb84c..ca7ada66d 100644 --- a/tests/modules/programs/himalaya/himalaya-expected.toml +++ b/tests/modules/programs/himalaya/himalaya-expected.toml @@ -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'" diff --git a/tests/modules/programs/himalaya/himalaya.nix b/tests/modules/programs/himalaya/himalaya.nix index 13872d158..4d556ff86 100644 --- a/tests/modules/programs/himalaya/himalaya.nix +++ b/tests/modules/programs/himalaya/himalaya.nix @@ -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; } ''; } -