mbsync: add options extraConfig.{channel|local|remote}
To allow supporting more advanced configurations. The local refers to
the "maildir store" configuration, remote to the "IMAP store", and
"channel" to the channel.
(cherry picked from commit 151f29a17a
)
This commit is contained in:
parent
9d7f7fe3a8
commit
b17b760755
|
@ -2,6 +2,12 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
extraConfigType = with lib.types; attrsOf (either (either str int) bool);
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options.mbsync = {
|
options.mbsync = {
|
||||||
enable = mkEnableOption "synchronization using mbsync";
|
enable = mkEnableOption "synchronization using mbsync";
|
||||||
|
@ -53,5 +59,35 @@ with lib;
|
||||||
Pattern of mailboxes to synchronize.
|
Pattern of mailboxes to synchronize.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraConfig.channel = mkOption {
|
||||||
|
type = extraConfigType;
|
||||||
|
default = {};
|
||||||
|
example = literalExample ''
|
||||||
|
{
|
||||||
|
MaxMessages = 10000;
|
||||||
|
MaxSize = "1m";
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Per channel extra configuration.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig.local = mkOption {
|
||||||
|
type = extraConfigType;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Local store extra configuration.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig.remote = mkOption {
|
||||||
|
type = extraConfigType;
|
||||||
|
default = {};
|
||||||
|
description = ''
|
||||||
|
Remote store extra configuration.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,14 @@ let
|
||||||
genSection = header: entries:
|
genSection = header: entries:
|
||||||
let
|
let
|
||||||
escapeValue = escape [ "\"" ];
|
escapeValue = escape [ "\"" ];
|
||||||
|
hasSpace = v: builtins.match ".* .*" v != null;
|
||||||
genValue = v:
|
genValue = v:
|
||||||
if isList v
|
if isList v
|
||||||
then concatMapStringsSep " " genValue v
|
then concatMapStringsSep " " genValue v
|
||||||
else "\"${escapeValue v}\"";
|
else if isBool v then (if v then "yes" else "no")
|
||||||
|
else if isInt v then toString v
|
||||||
|
else if hasSpace v then "\"${escapeValue v}\""
|
||||||
|
else v;
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
${header}
|
${header}
|
||||||
|
@ -54,15 +58,16 @@ let
|
||||||
User = userName;
|
User = userName;
|
||||||
PassCmd = toString passwordCommand;
|
PassCmd = toString passwordCommand;
|
||||||
}
|
}
|
||||||
//
|
// genTlsConfig imap.tls
|
||||||
genTlsConfig imap.tls
|
// optionalAttrs (imap.port != null) { Port = toString imap.port; }
|
||||||
//
|
|
||||||
optionalAttrs (imap.port != null) { Port = toString imap.port; }
|
|
||||||
)
|
)
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ genSection "IMAPStore ${name}-remote" {
|
+ genSection "IMAPStore ${name}-remote" (
|
||||||
Account = name;
|
{
|
||||||
}
|
Account = name;
|
||||||
|
}
|
||||||
|
// mbsync.extraConfig.remote
|
||||||
|
)
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ genSection "MaildirStore ${name}-local" (
|
+ genSection "MaildirStore ${name}-local" (
|
||||||
{
|
{
|
||||||
|
@ -70,19 +75,22 @@ let
|
||||||
Inbox = "${maildir.absPath}/${folders.inbox}";
|
Inbox = "${maildir.absPath}/${folders.inbox}";
|
||||||
SubFolders = "Verbatim";
|
SubFolders = "Verbatim";
|
||||||
}
|
}
|
||||||
//
|
// optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; }
|
||||||
optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; }
|
// mbsync.extraConfig.local
|
||||||
)
|
)
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ genSection "Channel ${name}" {
|
+ genSection "Channel ${name}" (
|
||||||
Master = ":${name}-remote:";
|
{
|
||||||
Slave = ":${name}-local:";
|
Master = ":${name}-remote:";
|
||||||
Patterns = mbsync.patterns;
|
Slave = ":${name}-local:";
|
||||||
Create = masterSlaveMapping.${mbsync.create};
|
Patterns = mbsync.patterns;
|
||||||
Remove = masterSlaveMapping.${mbsync.remove};
|
Create = masterSlaveMapping.${mbsync.create};
|
||||||
Expunge = masterSlaveMapping.${mbsync.expunge};
|
Remove = masterSlaveMapping.${mbsync.remove};
|
||||||
SyncState = "*";
|
Expunge = masterSlaveMapping.${mbsync.expunge};
|
||||||
}
|
SyncState = "*";
|
||||||
|
}
|
||||||
|
// mbsync.extraConfig.channel
|
||||||
|
)
|
||||||
+ "\n";
|
+ "\n";
|
||||||
|
|
||||||
genGroupConfig = name: channels:
|
genGroupConfig = name: channels:
|
||||||
|
|
Loading…
Reference in a new issue