2020-06-26 13:41:25 +02:00
|
|
|
{ config, lib, ... }:
|
2018-08-16 21:37:42 +02:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2018-09-02 07:58:54 +02:00
|
|
|
let
|
|
|
|
|
|
|
|
extraConfigType = with lib.types; attrsOf (either (either str int) bool);
|
|
|
|
|
2020-06-26 13:41:25 +02:00
|
|
|
perAccountGroups = { name, config, ... }: {
|
|
|
|
options = {
|
2020-06-26 20:38:40 +02:00
|
|
|
name = mkOption {
|
2020-06-26 13:41:25 +02:00
|
|
|
type = types.str;
|
2020-06-26 20:38:40 +02:00
|
|
|
# Make value of name the same as the name used with the dot prefix
|
2020-06-26 13:41:25 +02:00
|
|
|
default = name;
|
2020-06-26 20:38:40 +02:00
|
|
|
readOnly = true;
|
2020-06-26 13:41:25 +02:00
|
|
|
description = ''
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
channels = mkOption {
|
2020-06-26 20:38:40 +02:00
|
|
|
type = types.attrsOf (types.submodule channel);
|
2020-06-26 13:41:25 +02:00
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
List of channels that should be grouped together into this group. When
|
|
|
|
performing a synchronization, the groups are synchronized, rather than
|
|
|
|
the individual channels.
|
|
|
|
</para><para>
|
|
|
|
Using these channels and then grouping them together allows for you to
|
|
|
|
define the maildir hierarchy as you see fit.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-06-26 13:36:15 +02:00
|
|
|
# Options for configuring channel(s) that will be composed together into a group.
|
2020-06-26 20:38:40 +02:00
|
|
|
channel = { name, config, ... }: {
|
2020-06-26 13:36:15 +02:00
|
|
|
options = {
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
2020-06-26 20:38:40 +02:00
|
|
|
default = name;
|
|
|
|
readOnly = true;
|
2020-06-26 13:36:15 +02:00
|
|
|
description = ''
|
|
|
|
The unique name for THIS channel in THIS group. The group will refer to
|
|
|
|
this channel by this name.
|
|
|
|
</para><para>
|
|
|
|
In addition, you can manually sync just this channel by specifying this
|
|
|
|
name to mbsync on the command line.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
masterPattern = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2020-06-26 20:41:25 +02:00
|
|
|
example = "[Gmail]/Sent Mail";
|
2020-06-26 13:36:15 +02:00
|
|
|
description = ''
|
|
|
|
Regular expression pattern for which mailboxes on the remote mail server
|
|
|
|
to sync.
|
|
|
|
</para><para>
|
|
|
|
If this is left as the default, then mbsync will default to the pattern
|
|
|
|
<literal>INBOX</literal>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
slavePattern = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "";
|
2020-06-26 20:41:25 +02:00
|
|
|
example = "Sent";
|
2020-06-26 13:36:15 +02:00
|
|
|
description = ''
|
|
|
|
Name for where mail coming from the master mail server will end up
|
|
|
|
locally. The mailbox specified by the master's pattern will be placed
|
|
|
|
in this directory.
|
|
|
|
</para><para>
|
|
|
|
If this is left as the default, then mbsync will default to the pattern
|
|
|
|
<literal>INBOX</literal>.
|
|
|
|
'';
|
|
|
|
};
|
2020-06-27 02:18:50 +02:00
|
|
|
|
|
|
|
patterns = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "INBOX" ];
|
|
|
|
description = ''
|
|
|
|
Instead of synchronizing <emphasis>just</emphasis> the mailboxes that
|
|
|
|
match the <literal>masterPattern</literal>, use it as a prefix which is
|
|
|
|
not matched against the patterns, and is not affected by mailbox list
|
|
|
|
overrides.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-06-27 02:21:24 +02:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = extraConfigType;
|
|
|
|
default = { };
|
|
|
|
example = ''
|
|
|
|
{
|
|
|
|
Create = "both";
|
|
|
|
CopyArrivalDate = "yes";
|
|
|
|
MaxMessages = 10000;
|
|
|
|
MaxSize = "1m";
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Extra configuration lines to add to <emphasis>THIS</emphasis> channel's
|
|
|
|
configuration.
|
|
|
|
'';
|
|
|
|
};
|
2020-06-26 13:36:15 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-02 00:39:17 +01:00
|
|
|
in {
|
2018-08-16 21:37:42 +02:00
|
|
|
options.mbsync = {
|
|
|
|
enable = mkEnableOption "synchronization using mbsync";
|
|
|
|
|
|
|
|
flatten = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
|
|
|
example = ".";
|
|
|
|
description = ''
|
|
|
|
If set, flattens the hierarchy within the maildir by
|
|
|
|
substituting the canonical hierarchy delimiter
|
|
|
|
<literal>/</literal> with this value.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
create = mkOption {
|
|
|
|
type = types.enum [ "none" "maildir" "imap" "both" ];
|
|
|
|
default = "none";
|
|
|
|
example = "maildir";
|
|
|
|
description = ''
|
|
|
|
Automatically create missing mailboxes within the
|
|
|
|
given mail store.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
remove = mkOption {
|
|
|
|
type = types.enum [ "none" "maildir" "imap" "both" ];
|
|
|
|
default = "none";
|
|
|
|
example = "imap";
|
|
|
|
description = ''
|
|
|
|
Propagate mailbox deletions to the given mail store.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
expunge = mkOption {
|
|
|
|
type = types.enum [ "none" "maildir" "imap" "both" ];
|
|
|
|
default = "none";
|
|
|
|
example = "both";
|
|
|
|
description = ''
|
|
|
|
Permanently remove messages marked for deletion from
|
|
|
|
the given mail store.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
patterns = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ "*" ];
|
|
|
|
description = ''
|
|
|
|
Pattern of mailboxes to synchronize.
|
|
|
|
'';
|
|
|
|
};
|
2018-09-02 07:58:54 +02:00
|
|
|
|
2020-06-26 13:43:41 +02:00
|
|
|
groups = mkOption {
|
|
|
|
type = types.attrsOf (types.submodule perAccountGroups);
|
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
Some email providers (Gmail) have a different directory hierarchy for
|
|
|
|
synchronized email messages. Namely, when using mbsync without specifying
|
|
|
|
a set of channels into a group, all synchronized directories end up beneath
|
|
|
|
the <literal>[Gmail]/</literal> directory.
|
|
|
|
</para><para>
|
|
|
|
This option allows you to specify a group, and subsequently channels that
|
|
|
|
will allow you to sync your mail into an arbitrary hierarchy.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2018-09-02 07:58:54 +02:00
|
|
|
extraConfig.channel = mkOption {
|
|
|
|
type = extraConfigType;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = { };
|
2018-09-02 07:58:54 +02:00
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
MaxMessages = 10000;
|
|
|
|
MaxSize = "1m";
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Per channel extra configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig.local = mkOption {
|
|
|
|
type = extraConfigType;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = { };
|
2018-09-02 07:58:54 +02:00
|
|
|
description = ''
|
|
|
|
Local store extra configuration.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig.remote = mkOption {
|
|
|
|
type = extraConfigType;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = { };
|
2018-09-02 07:58:54 +02:00
|
|
|
description = ''
|
|
|
|
Remote store extra configuration.
|
|
|
|
'';
|
|
|
|
};
|
2018-10-03 20:35:04 +02:00
|
|
|
|
|
|
|
extraConfig.account = mkOption {
|
|
|
|
type = extraConfigType;
|
2020-02-02 00:39:17 +01:00
|
|
|
default = { };
|
2018-10-03 20:35:04 +02:00
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
PipelineDepth = 10;
|
|
|
|
Timeout = 60;
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Account section extra configuration.
|
|
|
|
'';
|
|
|
|
};
|
2018-08-16 21:37:42 +02:00
|
|
|
};
|
|
|
|
}
|