@@ -1,133 +1,81 @@
1−{ stdenv, fetchurl, pkgconfig
2−
3−# Optional Dependencies
4−, zlib ? null, openssl ? null, libssh2 ? null, libnghttp2 ? null, c-ares ? null
5−, gss ? null, rtmpdump ? null, openldap ? null, libidn ? null
6−
7−# Extra arguments
8−, suffix ? ""
1+{ stdenv, fetchurl
2+, idnSupport ? false, libidn ? null
3+, ldapSupport ? false, openldap ? null
4+, zlibSupport ? false, zlib ? null
5+, sslSupport ? false, openssl ? null
6+, scpSupport ? false, libssh2 ? null
7+, gssSupport ? false, gss ? null
8+, c-aresSupport ? false, c-ares ? null
99}:
1010
11−let
12− mkFlag = trueStr: falseStr: cond: name: val:
13− if cond == null then null else
14− "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
15− mkEnable = mkFlag "enable-" "disable-";
16− mkWith = mkFlag "with-" "without-";
17− mkOther = mkFlag "" "" true;
18−
19− shouldUsePkg = pkg: if pkg != null && stdenv.lib.any (x: x == stdenv.system) pkg.meta.platforms then pkg else null;
11+assert idnSupport -> libidn != null;
12+assert ldapSupport -> openldap != null;
13+assert zlibSupport -> zlib != null;
14+assert sslSupport -> openssl != null;
15+assert scpSupport -> libssh2 != null;
16+assert c-aresSupport -> c-ares != null;
2017
21− isLight = suffix == "light";
22− isFull = suffix == "full";
23− nameSuffix = stdenv.lib.optionalString (suffix != "") "-${suffix}";
24−
25− # Normal Depedencies
26− optZlib = if isLight then null else shouldUsePkg zlib;
27− optOpenssl = if isLight then null else shouldUsePkg openssl;
28− optLibssh2 = if isLight then null else shouldUsePkg libssh2;
29− optLibnghttp2 = if isLight then null else shouldUsePkg libnghttp2;
30− optC-ares = if isLight then null else shouldUsePkg c-ares;
31−
32− # Full dependencies
33− optGss = if !isFull then null else shouldUsePkg gss;
34− optRtmpdump = if !isFull then null else shouldUsePkg rtmpdump;
35− optOpenldap = if !isFull then null else shouldUsePkg openldap;
36− optLibidn = if !isFull then null else shouldUsePkg libidn;
37−in
38−with stdenv.lib;
3918stdenv.mkDerivation rec {
40− name = "curl${nameSuffix}-${version}";
41− version = "7.42.1";
19+ name = "curl-7.42.1";
4220
4321 src = fetchurl {
44− url = "http://curl.haxx.se/download/curl-${version}.tar.bz2";
22+ url = "http://curl.haxx.se/download/${name}.tar.bz2";
4523 sha256 = "11y8racpj6m4j9w7wa9sifmqvdgf22nk901sfkbxzhhy75rmk472";
4624 };
4725
48− # Use pkgconfig only when necessary
49− nativeBuildInputs = optional (!isLight) pkgconfig;
50− buildInputs = [
51− optZlib optOpenssl optLibssh2 optLibnghttp2 optC-ares
52− optGss optRtmpdump optOpenldap optLibidn
53− ];
26+ # Zlib and OpenSSL must be propagated because `libcurl.la' contains
27+ # "-lz -lssl", which aren't necessary direct build inputs of
28+ # applications that use Curl.
29+ propagatedBuildInputs = with stdenv.lib;
30+ optional idnSupport libidn ++
31+ optional ldapSupport openldap ++
32+ optional zlibSupport zlib ++
33+ optional gssSupport gss ++
34+ optional c-aresSupport c-ares ++
35+ optional sslSupport openssl ++
36+ optional scpSupport libssh2;
37+
38+ # for the second line see http://curl.haxx.se/mail/tracker-2014-03/0087.html
39+ preConfigure = ''
40+ sed -e 's|/usr/bin|/no-such-path|g' -i.bak configure
41+ rm src/tool_hugehelp.c
42+ '';
5443
55− # Make curl honor CURL_CA_BUNDLE & SSL_CERT_FILE
44+ # make curl honor CURL_CA_BUNDLE & SSL_CERT_FILE
5645 postConfigure = ''
57− echo '#define CURL_CA_BUNDLE (getenv("CURL_CA_BUNDLE") ? getenv("CURL_CA_BUNDLE") : getenv("SSL_CERT_FILE"))' >> lib/curl_config.h
46+ echo '#define CURL_CA_BUNDLE (getenv("CURL_CA_BUNDLE") ? getenv("CURL_CA_BUNDLE") : getenv("SSL_CERT_FILE"))' >> lib/curl_config.h
5847 '';
5948
6049 configureFlags = [
61− (mkEnable true "http" null)
62− (mkEnable true "ftp" null)
63− (mkEnable true "file" null)
64− (mkEnable (optOpenldap != null) "ldap" null)
65− (mkEnable (optOpenldap != null) "ldaps" null)
66− (mkEnable true "rtsp" null)
67− (mkEnable true "proxy" null)
68− (mkEnable true "dict" null)
69− (mkEnable true "telnet" null)
70− (mkEnable true "tftp" null)
71− (mkEnable true "pop3" null)
72− (mkEnable true "imap" null)
73− (mkEnable true "smb" null)
74− (mkEnable true "smtp" null)
75− (mkEnable true "gopher" null)
76− (mkEnable (!isLight) "manual" null)
77− (mkEnable true "libcurl_option" null)
78− (mkEnable false "libgcc" null) # TODO: Enable on gcc
79− (mkWith (optZlib != null) "zlib" null)
80− (mkEnable true "ipv4" null)
81− (mkWith (optGss != null) "gssapi" null)
82− (mkWith false "winssl" null)
83− (mkWith false "darwinssl" null)
84− (mkWith (optOpenssl != null) "ssl" null)
85− (mkWith false "gnutls" null)
86− (mkWith false "polarssl" null)
87− (mkWith false "cyassl" null)
88− (mkWith false "nss" null)
89− (mkWith false "axtls" null)
90− (mkWith false "libmetalink" null)
91− (mkWith (optLibssh2 != null) "libssh2" null)
92− (mkWith (optRtmpdump!= null) "librtmp" null)
93− (mkEnable false "versioned-symbols" null)
94− (mkWith false "winidn" null)
95− (mkWith (optLibidn != null) "libidn" null)
96− (mkWith (optLibnghttp2 != null) "nghttp2" null)
97− (mkEnable false "sspi" null)
98− (mkEnable true "crypto-auth" null)
99− (mkEnable (optOpenssl != null) "tls-srp" null)
100− (mkEnable true "unix-sockets" null)
101− (mkEnable true "cookies" null)
102− (mkEnable (optC-ares != null) "ares" null)
103− ];
50+ ( if sslSupport then "--with-ssl=${openssl}" else "--without-ssl" )
51+ ( if scpSupport then "--with-libssh2=${libssh2}" else "--without-libssh2" )
52+ ( if ldapSupport then "--enable-ldap" else "--disable-ldap" )
53+ ( if ldapSupport then "--enable-ldaps" else "--disable-ldaps" )
54+ ( if idnSupport then "--with-libidn=${libidn}" else "--without-libidn" )
55+ ]
56+ ++ stdenv.lib.optional c-aresSupport "--enable-ares=${c-ares}"
57+ ++ stdenv.lib.optional gssSupport "--with-gssapi=${gss}";
10458
105− # Fix all broken refernces to dependencies in .la and .pc files
106− postInstall = optionalString (optZlib != null) ''
107− sed -i 's,\(-lz\),-L${optZlib}/lib \1,' $out/lib/{libcurl.la,pkgconfig/libcurl.pc}
108− '' + optionalString (optOpenssl != null) ''
109− sed -i 's,\(-lssl\|-lcrypto\),-L${optOpenssl}/lib \1,' $out/lib/pkgconfig/libcurl.pc
110− '' + optionalString (optLibssh2 != null) ''
111− sed -i 's,\(-lssh2\),-L${optLibssh2}/lib \1,' $out/lib/pkgconfig/libcurl.pc
112− '' + optionalString (optLibnghttp2 != null) ''
113− sed -i 's,\(-lnghttp2\),-L${optLibnghttp2}/lib \1,' $out/lib/pkgconfig/libcurl.pc
114− '' + optionalString (optC-ares != null) ''
115− sed -i 's,\(-lcares\),-L${optC-ares}/lib \1,' $out/lib/{libcurl.la,pkgconfig/libcurl.pc}
116− '' + optionalString (optGss != null) ''
117− sed -i 's,\(-lgss\),-L${optGss}/lib \1,' $out/lib/{libcurl.la,pkgconfig/libcurl.pc}
118− '' + optionalString (optRtmpdump != null) ''
119− sed -i 's,\(-lrtmp\),-L${optRtmpdump}/lib \1,' $out/lib/pkgconfig/libcurl.pc
120− '' + optionalString (optOpenldap != null) ''
121− sed -i 's,\(-lgss\),-L${optOpenldap}/lib \1,' $out/lib/{libcurl.la,pkgconfig/libcurl.pc}
122− '' + optionalString (optLibidn != null) ''
123− sed -i 's,\(-lidn\),-L${optLibidn}/lib \1,' $out/lib/pkgconfig/libcurl.pc
124− '';
59+ CXX = "g++";
60+ CXXCPP = "g++ -E";
61+
62+ crossAttrs = {
63+ # We should refer to the cross built openssl
64+ # For the 'urandom', maybe it should be a cross-system option
65+ configureFlags = [
66+ ( if sslSupport then "--with-ssl=${openssl.crossDrv}" else "--without-ssl" )
67+ "--with-random /dev/urandom"
68+ ];
69+ };
70+
71+ passthru = {
72+ inherit sslSupport openssl;
73+ };
12574
126− meta = {
75+ meta = with stdenv.lib; {
12776 description = "A command line tool for transferring files with URL syntax";
12877 homepage = http://curl.haxx.se/;
129− license = licenses.mit;
78+ maintainers = with maintainers; [ lovek323 ];
13079 platforms = platforms.all;
131− maintainers = with maintainers; [ lovek323 wkennington ];
13280 };
13381}