1{ lib, stdenv, fetchurl, pkg-config, perl
2, openssl, db, cyrus_sasl, zlib
3, Security
4# Disabled by default as XOAUTH2 is an "OBSOLETE" SASL mechanism and this relies
5# on a package that isn't really maintained anymore:
6, withCyrusSaslXoauth2 ? false, cyrus-sasl-xoauth2, makeWrapper
7}:
8
9stdenv.mkDerivation rec {
10 pname = "isync";
11 version = "1.4.4";
12
13 src = fetchurl {
14 url = "mirror://sourceforge/isync/${pname}-${version}.tar.gz";
15 sha256 = "1zq0wwvmqsl9y71546dr0aygzn9gjjfiw19hlcq87s929y4p6ckw";
16 };
17
18 patches = [
19 # Fixes "Fatal: buffer too small" error
20 ./0001-Increase-imap_vprintf-buffer-size.patch
21 # Fix #202595: SSL error "Socket error: ... unexpected eof while reading"
22 # Source: https://sourceforge.net/p/isync/isync/ci/b6c36624f04cd388873785c0631df3f2f9ac4bf0/
23 ./work-around-unexpected-EOF-error-messages-at-end-of-SSL-connections.patch
24 ];
25
26 nativeBuildInputs = [ pkg-config perl ]
27 ++ lib.optionals withCyrusSaslXoauth2 [ makeWrapper ];
28 buildInputs = [ openssl db cyrus_sasl zlib ]
29 ++ lib.optionals stdenv.isDarwin [ Security ];
30
31 postInstall = lib.optionalString withCyrusSaslXoauth2 ''
32 wrapProgram "$out/bin/mbsync" \
33 --prefix SASL_PATH : "${lib.makeSearchPath "lib/sasl2" [ cyrus-sasl-xoauth2 ]}"
34 '';
35
36 meta = with lib; {
37 homepage = "http://isync.sourceforge.net/";
38 # https://sourceforge.net/projects/isync/
39 changelog = "https://sourceforge.net/p/isync/isync/ci/v${version}/tree/NEWS";
40 description = "Free IMAP and MailDir mailbox synchronizer";
41 longDescription = ''
42 mbsync (formerly isync) is a command line application which synchronizes
43 mailboxes. Currently Maildir and IMAP4 mailboxes are supported. New
44 messages, message deletions and flag changes can be propagated both ways.
45 '';
46 license = licenses.gpl2Plus;
47 platforms = platforms.unix;
48 maintainers = with maintainers; [ primeos lheckemann ];
49 mainProgram = "mbsync";
50 };
51}