1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-28 09:28:32 +02:00

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.
This commit is contained in:
Matthieu Coudron 2018-09-02 14:58:54 +09:00 committed by Robert Helgesson
parent f7dc354f42
commit 151f29a17a
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
2 changed files with 63 additions and 19 deletions

View File

@ -2,6 +2,12 @@
with lib;
let
extraConfigType = with lib.types; attrsOf (either (either str int) bool);
in
{
options.mbsync = {
enable = mkEnableOption "synchronization using mbsync";
@ -53,5 +59,35 @@ with lib;
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.
'';
};
};
}

View File

@ -33,10 +33,14 @@ let
genSection = header: entries:
let
escapeValue = escape [ "\"" ];
hasSpace = v: builtins.match ".* .*" v != null;
genValue = v:
if isList 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
''
${header}
@ -54,15 +58,16 @@ let
User = userName;
PassCmd = toString passwordCommand;
}
//
genTlsConfig imap.tls
//
optionalAttrs (imap.port != null) { Port = toString imap.port; }
// genTlsConfig imap.tls
// optionalAttrs (imap.port != null) { Port = toString imap.port; }
)
+ "\n"
+ genSection "IMAPStore ${name}-remote" {
Account = name;
}
+ genSection "IMAPStore ${name}-remote" (
{
Account = name;
}
// mbsync.extraConfig.remote
)
+ "\n"
+ genSection "MaildirStore ${name}-local" (
{
@ -70,19 +75,22 @@ let
Inbox = "${maildir.absPath}/${folders.inbox}";
SubFolders = "Verbatim";
}
//
optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; }
// optionalAttrs (mbsync.flatten != null) { Flatten = mbsync.flatten; }
// mbsync.extraConfig.local
)
+ "\n"
+ genSection "Channel ${name}" {
Master = ":${name}-remote:";
Slave = ":${name}-local:";
Patterns = mbsync.patterns;
Create = masterSlaveMapping.${mbsync.create};
Remove = masterSlaveMapping.${mbsync.remove};
Expunge = masterSlaveMapping.${mbsync.expunge};
SyncState = "*";
}
+ genSection "Channel ${name}" (
{
Master = ":${name}-remote:";
Slave = ":${name}-local:";
Patterns = mbsync.patterns;
Create = masterSlaveMapping.${mbsync.create};
Remove = masterSlaveMapping.${mbsync.remove};
Expunge = masterSlaveMapping.${mbsync.expunge};
SyncState = "*";
}
// mbsync.extraConfig.channel
)
+ "\n";
genGroupConfig = name: channels: