mbsync: set the submodule's names field according to parameter

This is the same method as is used in creating an email account, named
`<name>` under `accounts.email.accounts.<name>`. This allows the user
to specify groups and channels, in a list-like format, but still gets
the "namespacing" to more easily handle the options available in each
of these locations.
This commit is contained in:
Karl Hallsby 2020-06-26 20:38:40 +02:00
parent f9d8aa6b25
commit c072526cfa

View file

@ -8,9 +8,11 @@ let
perAccountGroups = { name, config, ... }: { perAccountGroups = { name, config, ... }: {
options = { options = {
groupName = mkOption { name = mkOption {
type = types.str; type = types.str;
# Make value of name the same as the name used with the dot prefix
default = name; default = name;
readOnly = true;
description = '' description = ''
The name of this group for this account. These names are different than The name of this group for this account. These names are different than
some others, because they will hide channel names that are the same. some others, because they will hide channel names that are the same.
@ -18,7 +20,7 @@ let
}; };
channels = mkOption { channels = mkOption {
type = types.listOf (types.submodule groupChannel); type = types.attrsOf (types.submodule channel);
default = { }; default = { };
description = '' description = ''
List of channels that should be grouped together into this group. When List of channels that should be grouped together into this group. When
@ -33,11 +35,12 @@ let
}; };
# Options for configuring channel(s) that will be composed together into a group. # Options for configuring channel(s) that will be composed together into a group.
groupChannel = { config, ... }: { channel = { name, config, ... }: {
options = { options = {
name = mkOption { name = mkOption {
type = types.str; type = types.str;
default = "DEFAULT"; default = name;
readOnly = true;
description = '' description = ''
The unique name for THIS channel in THIS group. The group will refer to The unique name for THIS channel in THIS group. The group will refer to
this channel by this name. this channel by this name.