From 41790ba656bafc023f48ccdbbe7816d30fd52d76 Mon Sep 17 00:00:00 2001 From: David Baynard Date: Mon, 19 Sep 2022 22:19:21 +0100 Subject: [PATCH] mbsync: extend config type with list of strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some configuration options can take space separated strings; for example `SSLVersions` can be configured with multiple allowed versions. SSLVersions TLSv1.3 TLSv1.2 This can now be represented in Home Manager. SSLVersions = [ “TLSv1.3” “TLSv1.2” ]; In implementing this change, it uses oneOf for config type, as it is a cleaner way to represent the union than the nested eithers formulation. Also add SSLVersions to test lists of strings in `account.extraConfig`. --- modules/programs/mbsync-accounts.nix | 3 ++- tests/modules/programs/mbsync/mbsync-expected.conf | 1 + tests/modules/programs/mbsync/mbsync.nix | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/programs/mbsync-accounts.nix b/modules/programs/mbsync-accounts.nix index fa3f00ab..af368b9d 100644 --- a/modules/programs/mbsync-accounts.nix +++ b/modules/programs/mbsync-accounts.nix @@ -4,7 +4,8 @@ with lib; let - extraConfigType = with lib.types; attrsOf (either (either str int) bool); + extraConfigType = with lib.types; + attrsOf (oneOf [ str int bool (listOf str) ]); perAccountGroups = { name, config, ... }: { options = { diff --git a/tests/modules/programs/mbsync/mbsync-expected.conf b/tests/modules/programs/mbsync/mbsync-expected.conf index c1ca921a..17110978 100644 --- a/tests/modules/programs/mbsync/mbsync-expected.conf +++ b/tests/modules/programs/mbsync/mbsync-expected.conf @@ -57,6 +57,7 @@ CertificateFile /etc/ssl/certs/ca-certificates.crt Host imap.example.com PassCmd password-command SSLType IMAPS +SSLVersions TLSv1.3 TLSv1.2 User home.manager IMAPStore hm@example.com-remote diff --git a/tests/modules/programs/mbsync/mbsync.nix b/tests/modules/programs/mbsync/mbsync.nix index 7042760a..862e1c0e 100644 --- a/tests/modules/programs/mbsync/mbsync.nix +++ b/tests/modules/programs/mbsync/mbsync.nix @@ -21,6 +21,7 @@ with lib; accounts.email.accounts = { "hm@example.com".mbsync = { enable = true; + extraConfig.account.SSLVersions = [ "TLSv1.3" "TLSv1.2" ]; groups.inboxes = { channels = { inbox1 = {