Skip to content

Commit

Permalink
isync/mbsync: update module for 1.5.0 changes (nix-community#5918)
Browse files Browse the repository at this point in the history
* mbsync: Add NEWS entry about isync 1.5.0 changes

* mbsync: Place config file in $XDG_CONFIG_HOME

mbsync 1.5.0 supports placing isync's configuration file in
$XDG_CONFIG_HOME/isyncrc [1].

[1] https://sourceforge.net/projects/isync/files/isync/1.5.0/

* mbsync: Replace SSLType with TLSType

mbsync 1.5.0 replaced the name of the configuration option [1].

Also update SSLVersions to TLSVersions for the same reason. Inform the
user if the option was renamed.

[1] https://sourceforge.net/projects/isync/files/isync/1.5.0/

* mbsync: Replace SSLVersions with TLSVerisons

* mbsync: Update extraConfig.account example with SSL->TLS changes
  • Loading branch information
KarlJoad authored Dec 9, 2024
1 parent d00c6f6 commit f63c15c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
29 changes: 29 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,35 @@ in {
Some plugins require this to be set to 'false' to function correctly.
'';
}

{
time = "2024-12-08T17:22:13+00:00";
condition = let
usingMbsync = any (a: a.mbsync.enable)
(attrValues config.accounts.email.accounts);
in usingMbsync;
message = ''
isync/mbsync 1.5.0 has changed several things.
isync gained support for using $XDG_CONFIG_HOME, and now places
its config file in '$XDG_CONFIG_HOME/isyncrc'.
isync changed the configuration options SSLType and SSLVersion to
TLSType and TLSVersion respectively.
All instances of
'accounts.email.accounts.<account-name>.mbsync.extraConfig.account'
that use 'SSLType' or 'SSLVersion' should be replaced with 'TLSType'
or 'TLSVersion', respectively.
TLSType options are unchanged.
TLSVersions has a new syntax, requiring a change to the Nix syntax.
Old Syntax: SSLVersions = [ "TLSv1.3" "TLSv1.2" ];
New Syntax: TLSVersions = [ "+1.3" "+1.2" "-1.1" ];
NOTE: The minus symbol means to NOT use that particular TLS version.
'';
}
];
};
}
2 changes: 2 additions & 0 deletions modules/programs/mbsync-accounts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ in {
default = { };
example = literalExpression ''
{
TLSType = "IMAP";
TLSVersions = [ "+1.3" "+1.2" "-1.1" ];
PipelineDepth = 10;
Timeout = 60;
};
Expand Down
4 changes: 2 additions & 2 deletions modules/programs/mbsync.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let

genTlsConfig = tls:
{
SSLType = if !tls.enable then
TLSType = if !tls.enable then
"None"
else if tls.useStartTls then
"STARTTLS"
Expand Down Expand Up @@ -267,7 +267,7 @@ in {

programs.notmuch.new.ignore = [ ".uidvalidity" ".mbsyncstate" ];

home.file.".mbsyncrc".text = let
xdg.configFile."isyncrc".text = let
accountsConfig = map genAccountConfig mbsyncAccounts;
# Only generate this kind of Group configuration if there are ANY accounts
# that do NOT have a per-account groups/channels option(s) specified.
Expand Down
6 changes: 3 additions & 3 deletions tests/modules/programs/mbsync/mbsync-expected.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ IMAPAccount hm-account
CertificateFile /etc/ssl/certs/ca-certificates.crt
Host imap.example.org
PassCmd "password-command 2"
SSLType IMAPS
TLSType IMAPS
User home.manager.jr

IMAPStore hm-account-remote
Expand Down Expand Up @@ -56,8 +56,8 @@ IMAPAccount [email protected]
CertificateFile /etc/ssl/certs/ca-certificates.crt
Host imap.example.com
PassCmd password-command
SSLType IMAPS
SSLVersions TLSv1.3 TLSv1.2
TLSType IMAPS
TLSVersions +1.3 +1.2 -1.1
User home.manager

IMAPStore [email protected]
Expand Down
6 changes: 3 additions & 3 deletions tests/modules/programs/mbsync/mbsync.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ with lib;
accounts.email.accounts = {
"[email protected]".mbsync = {
enable = true;
extraConfig.account.SSLVersions = [ "TLSv1.3" "TLSv1.2" ];
extraConfig.account.TLSVersions = [ "+1.3" "+1.2" "-1.1" ];
groups.inboxes = {
channels = {
inbox1 = {
Expand Down Expand Up @@ -79,8 +79,8 @@ with lib;
test.stubs.isync = { };

nmt.script = ''
assertFileExists home-files/.mbsyncrc
assertFileContent home-files/.mbsyncrc ${./mbsync-expected.conf}
assertFileExists home-files/.config/isyncrc
assertFileContent home-files/.config/isyncrc ${./mbsync-expected.conf}
'';
};
}

0 comments on commit f63c15c

Please sign in to comment.