mirror of
https://github.com/nix-community/home-manager
synced 2024-11-13 22:59:44 +01:00
mbsync: write function to generate channel configuration blocks
This function takes in a set of groups, which includes their consituent channels and writes the appropriate .mbsyncrc block for the channel. The block that is generated is shown below: Channel groupName1-channelName1 Master :<accountName>-remote:<master-pattern> Slave :<accountName>-local:<slave-pattern> Channel groupName2-channelName2 Master :<accountName>-remote:<master-pattern> Slave :<accountName>-local:<slave-pattern> Each group must have a unique name, no matter which account it is declared under. The same holds true for channels. Using channels with the patterns set up this way allows one to specify which maildir directories are to be synchronized FROM the master TO the slave. In addition, it allows for these maildirs to be remapped, between the master server and the local slave. This is critical, because Gmail has a strange way of storing its mail that makes using mbsync, mu, and mu4e more difficult. There are additional channel parameters that are already present in this codebase from the previous use of group-channel configuration, which will be reused.
This commit is contained in:
parent
e469020cb0
commit
f9d8aa6b25
1 changed files with 25 additions and 0 deletions
|
@ -79,6 +79,31 @@ let
|
|||
SyncState = "*";
|
||||
} // mbsync.extraConfig.channel) + "\n";
|
||||
# Given the attr set of groups, return a string of channels to put into each group.
|
||||
# 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.
|
||||
genGroupChannelConfig = storeName: groups:
|
||||
let
|
||||
# Given the name of the group this channel is part of and the channel
|
||||
# itself, generate the string for the desired configuration.
|
||||
genChannelString = groupName: channel:
|
||||
genSection "Channel ${groupName}-${channel.name}" ({
|
||||
Master = ":${storeName}-remote:${channel.masterPattern}";
|
||||
Slave = ":${storeName}-local:${channel.slavePattern}";
|
||||
}) + "\n";
|
||||
# Given the group name, and a attr set of channels within that group,
|
||||
# Generate a list of strings for each channels' configuration.
|
||||
genChannelStrings = groupName: channels:
|
||||
mapAttrsToList (channelName: info: genChannelString groupName info) channels;
|
||||
# Given a group, return a string that configures all the channels within
|
||||
# the group.
|
||||
genGroupsChannels = group: concatStrings
|
||||
(genChannelStrings group.name group.channels);
|
||||
in
|
||||
# Generate all channel configurations for all groups for this account.
|
||||
concatStringsSep "\n"
|
||||
(mapAttrsToList (name: group: genGroupsChannels group) groups);
|
||||
|
||||
# Given the attr set of groups, return a string which maps channels to groups
|
||||
genAccountGroups = groups:
|
||||
let
|
||||
|
|
Loading…
Reference in a new issue