From b1a241ff9fb5a40bba41de4ff5dc1a69d7ed0add Mon Sep 17 00:00:00 2001 From: Karl Hallsby <karl@hallsby.com> Date: Sat, 27 Jun 2020 22:19:40 +0200 Subject: [PATCH] mbsync: channel compatibility with previous iteration of mbsync The previous version of mbsync used a single channel for an entire account. This leads to issues when trying to change the mailbox hierarchy on the local machine. The problem with this is that some email providers (Gmail, among others) use a slightly different maildir hierarchy, where the standard mailboxes (Inbox, Drafts, Trash, etc.) are stored inside another directory (`[Gmail]/` in the case of Gmail). This new version allows the user to specify any number of groups with any number of channels within to reorder their mail however they wish. However, to maintain backwards compatibility, I moved the original channel-generating code to a function that will run ONLY when there are no groups specified for THIS account. --- modules/programs/mbsync.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/programs/mbsync.nix b/modules/programs/mbsync.nix index 7bfc48267..bf9915394 100644 --- a/modules/programs/mbsync.nix +++ b/modules/programs/mbsync.nix @@ -73,6 +73,21 @@ let + genGroupChannelConfig name mbsync.groups + genAccountGroups mbsync.groups; + genAccountWideChannel = account: + with account; + if mbsync != {} then + genSection "Channel ${name}" ({ + Master = ":${name}-remote:"; + Slave = ":${name}-local:"; + Patterns = mbsync.patterns; + Create = masterSlaveMapping.${mbsync.create}; + Remove = masterSlaveMapping.${mbsync.remove}; + Expunge = masterSlaveMapping.${mbsync.expunge}; + SyncState = "*"; + } // mbsync.extraConfig.channel) + "\n" + else + ""; + # Given the attr set of groups, return a string of channels that will direct # mail to the proper directories, according to the pattern used in channel's # master pattern definition.