mbsync: write function to generate group-channel blocks
This function takes in a set of groups, and their consituent channels and writes the appropriate .mbsyncrc block. The block is as shown below: Group groupName1 Channel channelName1 Channel channelName2 Group groupName2 Channel channelName3 Each group must have a unique name, no matter which account it is declared under. The same holds true for channels. However, if there is a group that shares the same name as the channel, the channel will effectively be "shadowed" by the group, and mbsync will default to working with the group in that case.
This commit is contained in:
parent
00e4a33cd1
commit
e469020cb0
|
@ -78,6 +78,27 @@ let
|
||||||
Expunge = masterSlaveMapping.${mbsync.expunge};
|
Expunge = masterSlaveMapping.${mbsync.expunge};
|
||||||
SyncState = "*";
|
SyncState = "*";
|
||||||
} // mbsync.extraConfig.channel) + "\n";
|
} // 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 which maps channels to groups
|
||||||
|
genAccountGroups = groups:
|
||||||
|
let
|
||||||
|
# Given the name of the group and the attribute set of channels, make
|
||||||
|
# make "Channel <grpName>-<chnName>" for each channel to list os strings
|
||||||
|
genChannelStrings = groupName: channels: mapAttrsToList
|
||||||
|
(name: info: "Channel ${groupName}-${name}") channels;
|
||||||
|
# Take in 1 group, construct the "Group <grpName>" header, and construct
|
||||||
|
# each of the channels.
|
||||||
|
genGroupChannelString = group:
|
||||||
|
[("Group " + group.name)] ++
|
||||||
|
(genChannelStrings group.name group.channels);
|
||||||
|
# Given set of groups, generates list of strings, where each string is one
|
||||||
|
# of the groups and its consituent channels.
|
||||||
|
genGroupsStrings = mapAttrsToList (name: info: concatStringsSep "\n"
|
||||||
|
(genGroupChannelString groups.${name})) groups;
|
||||||
|
in (concatStringsSep "\n\n" genGroupsStrings) # Put all strings together.
|
||||||
|
# 2 \n needed in concatStringsSep because last element genGroupsStrings
|
||||||
|
# has no \n.
|
||||||
|
+ "\n\n"; # Additional spacing after this account's group setup.
|
||||||
|
|
||||||
genGroupConfig = name: channels:
|
genGroupConfig = name: channels:
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in a new issue