From 6dfa9ef85cf4e23ec42f34c9e988baaf793617a1 Mon Sep 17 00:00:00 2001 From: yoctocell Date: Sat, 6 Feb 2021 21:25:49 +0000 Subject: [PATCH] mbsync: add subFolders option (#1760) The `SubFolders` option in mbsync controls the folder naming style in the maildir. There are three different styles: * Verbatim - /top/sub/subsub * Maildir++ - /.top.sub.subsub (used by Dovecot) * Legacy - /top/.sub/.subsub Previously, the `SubFolders` option was hardcoded to `Verbatim`. This change allows configuration of the `SubFolders` option. --- modules/programs/mbsync-accounts.nix | 10 ++++++++++ modules/programs/mbsync.nix | 9 ++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/programs/mbsync-accounts.nix b/modules/programs/mbsync-accounts.nix index c1bd551fa..cdd5997f1 100644 --- a/modules/programs/mbsync-accounts.nix +++ b/modules/programs/mbsync-accounts.nix @@ -125,6 +125,16 @@ in { ''; }; + subFolders = mkOption { + type = types.enum [ "Verbatim" "Maildir++" "Legacy" ]; + default = "Verbatim"; + example = "Maildir++"; + description = '' + The on-disk folder naming style. This option has no + effect when is used. + ''; + }; + create = mkOption { type = types.enum [ "none" "maildir" "imap" "both" ]; default = "none"; diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index f9713da3a..7d55c7343 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -65,10 +65,13 @@ let + genSection "IMAPStore ${name}-remote" ({ Account = name; } // mbsync.extraConfig.remote) + "\n" + genSection "MaildirStore ${name}-local" ({ - Path = "${maildir.absPath}/"; Inbox = "${maildir.absPath}/${folders.inbox}"; - SubFolders = "Verbatim"; - } // optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; } + } // optionalAttrs + (mbsync.subFolders != "Maildir++" || mbsync.flatten != null) { + Path = "${maildir.absPath}/"; + } // optionalAttrs (mbsync.flatten == null) { + SubFolders = mbsync.subFolders; + } // optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; } // mbsync.extraConfig.local) + "\n" + genChannels account; genChannels = account: