@@ -0,0 +1,113 @@
1+{ stdenv, lib, fetchurl, pkgconfig, perl
2+, http2Support ? true, nghttp2
3+, idnSupport ? false, libidn ? null
4+, ldapSupport ? false, openldap ? null
5+, zlibSupport ? false, zlib ? null
6+, sslSupport ? false, openssl ? null
7+, gnutlsSupport ? false, gnutls ? null
8+, scpSupport ? false, libssh2 ? null
9+, gssSupport ? false, kerberos ? null
10+, c-aresSupport ? false, c-ares ? null
11+, brotliSupport ? false, brotli ? null
12+}:
13+
14+assert http2Support -> nghttp2 != null;
15+assert idnSupport -> libidn != null;
16+assert ldapSupport -> openldap != null;
17+assert zlibSupport -> zlib != null;
18+assert sslSupport -> openssl != null;
19+assert !(gnutlsSupport && sslSupport);
20+assert gnutlsSupport -> gnutls != null;
21+assert scpSupport -> libssh2 != null;
22+assert c-aresSupport -> c-ares != null;
23+assert brotliSupport -> brotli != null;
24+assert gssSupport -> kerberos != null;
25+
26+stdenv.mkDerivation rec {
27+ name = "curl-7.59.0";
28+
29+ src = fetchurl {
30+ urls = [
31+ "https://github.com/curl/curl/releases/download/${lib.replaceStrings ["."] ["_"] name}/${name}.tar.bz2"
32+ "https://curl.haxx.se/download/${name}.tar.bz2"
33+ ];
34+ sha256 = "185mazhi4bc5mc6rvhrmnc67j8l3sg7f0w2hp5gmi5ccdbyhz4mm";
35+ };
36+
37+ outputs = [ "bin" "dev" "out" "man" "devdoc" ];
38+ separateDebugInfo = stdenv.isLinux;
39+
40+ enableParallelBuilding = true;
41+
42+ nativeBuildInputs = [ pkgconfig perl ];
43+
44+ # Zlib and OpenSSL must be propagated because `libcurl.la' contains
45+ # "-lz -lssl", which aren't necessary direct build inputs of
46+ # applications that use Curl.
47+ propagatedBuildInputs = with stdenv.lib;
48+ optional http2Support nghttp2 ++
49+ optional idnSupport libidn ++
50+ optional ldapSupport openldap ++
51+ optional zlibSupport zlib ++
52+ optional gssSupport kerberos ++
53+ optional c-aresSupport c-ares ++
54+ optional sslSupport openssl ++
55+ optional gnutlsSupport gnutls ++
56+ optional scpSupport libssh2 ++
57+ optional brotliSupport brotli;
58+
59+ # for the second line see https://curl.haxx.se/mail/tracker-2014-03/0087.html
60+ preConfigure = ''
61+ sed -e 's|/usr/bin|/no-such-path|g' -i.bak configure
62+ rm src/tool_hugehelp.c
63+ '';
64+
65+ configureFlags = [
66+ "--with-ca-fallback"
67+ "--disable-manual"
68+ ( if sslSupport then "--with-ssl=${openssl.dev}" else "--without-ssl" )
69+ ( if gnutlsSupport then "--with-gnutls=${gnutls.dev}" else "--without-gnutls" )
70+ ( if scpSupport then "--with-libssh2=${libssh2.dev}" else "--without-libssh2" )
71+ ( if ldapSupport then "--enable-ldap" else "--disable-ldap" )
72+ ( if ldapSupport then "--enable-ldaps" else "--disable-ldaps" )
73+ ( if idnSupport then "--with-libidn=${libidn.dev}" else "--without-libidn" )
74+ ( if brotliSupport then "--with-brotli" else "--without-brotli" )
75+ ]
76+ ++ stdenv.lib.optional c-aresSupport "--enable-ares=${c-ares}"
77+ ++ stdenv.lib.optional gssSupport "--with-gssapi=${kerberos.dev}";
78+
79+ CXX = "${stdenv.cc.targetPrefix}c++";
80+ CXXCPP = "${stdenv.cc.targetPrefix}c++ -E";
81+
82+ doCheck = false; # expensive, fails
83+
84+ postInstall = ''
85+ moveToOutput bin/curl-config "$dev"
86+ sed '/^dependency_libs/s|${libssh2.dev}|${libssh2.out}|' -i "$out"/lib/*.la
87+ '' + stdenv.lib.optionalString gnutlsSupport ''
88+ ln $out/lib/libcurl.so $out/lib/libcurl-gnutls.so
89+ ln $out/lib/libcurl.so $out/lib/libcurl-gnutls.so.4
90+ ln $out/lib/libcurl.so $out/lib/libcurl-gnutls.so.4.4.0
91+ '';
92+
93+ crossAttrs = {
94+ # We should refer to the cross built openssl
95+ # For the 'urandom', maybe it should be a cross-system option
96+ configureFlags = [
97+ ( if sslSupport then "--with-ssl=${openssl.crossDrv}" else "--without-ssl" )
98+ ( if gnutlsSupport then "--with-gnutls=${gnutls.crossDrv}" else "--without-gnutls" )
99+ "--with-random /dev/urandom"
100+ ];
101+ };
102+
103+ passthru = {
104+ inherit sslSupport openssl;
105+ };
106+
107+ meta = with stdenv.lib; {
108+ description = "A command line tool for transferring files with URL syntax";
109+ homepage = https://curl.haxx.se/;
110+ maintainers = with maintainers; [ lovek323 ];
111+ platforms = platforms.all;
112+ };
113+}