Skip to content

Instantly share code, notes, and snippets.

@AcouBass
Last active September 10, 2016 00:54
Show Gist options
  • Save AcouBass/29b4c96888dec84da73d2e737e459a51 to your computer and use it in GitHub Desktop.
Save AcouBass/29b4c96888dec84da73d2e737e459a51 to your computer and use it in GitHub Desktop.
curl compat - no versioned symbols, for runescape nix
{ stdenv, fetchurl, gnutls, pkgconfig, perl
, http2Support ? false, nghttp2
, idnSupport ? false, libidn ? null
, ldapSupport ? false, openldap ? null
, zlibSupport ? false, zlib ? null
, sslSupport ? false, openssl ? null
, scpSupport ? false, libssh2 ? null
, gssSupport ? false, gss ? null
, c-aresSupport ? false, c-ares ? null
}:
assert http2Support -> nghttp2 != null;
assert idnSupport -> libidn != null;
assert ldapSupport -> openldap != null;
assert zlibSupport -> zlib != null;
assert sslSupport -> openssl != null;
assert scpSupport -> libssh2 != null;
assert c-aresSupport -> c-ares != null;
stdenv.mkDerivation rec {
name = "curl-7.50.1";
src = fetchurl {
url = "http://curl.haxx.se/download/${name}.tar.bz2";
sha256 = "0mjidq4q0hikhis2d35kzkhx6xfcgl875mk5ph5d98fa9kswa4iw";
};
outputs = [ "dev" "out" "bin" "man" ];
nativeBuildInputs = [ pkgconfig perl ];
# Zlib and OpenSSL must be propagated because `libcurl.la' contains
# "-lz -lssl", which aren't necessary direct build inputs of
# applications that use Curl.
propagatedBuildInputs = with stdenv.lib;
optional http2Support nghttp2 ++
optional idnSupport libidn ++
optional ldapSupport openldap ++
optional zlibSupport zlib ++
optional gssSupport gss ++
optional c-aresSupport c-ares ++
optional sslSupport openssl ++
optional scpSupport libssh2;
# for the second line see http://curl.haxx.se/mail/tracker-2014-03/0087.html
preConfigure = ''
sed -e 's|/usr/bin|/no-such-path|g' -i.bak configure
rm src/tool_hugehelp.c
'';
configureFlags = [
"--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt"
"--disable-manual"
"--disable-versioned-symbols"
"--enable-threaded-resolver"
"--enable-ipv6"
"--with-gssapi"
( if sslSupport then "--with-ssl=${openssl.dev}" else "--without-ssl" )
( if scpSupport then "--with-libssh2=${libssh2.dev}" else "--without-libssh2" )
( if ldapSupport then "--enable-ldap" else "--disable-ldap" )
( if ldapSupport then "--enable-ldaps" else "--disable-ldaps" )
( if idnSupport then "--with-libidn=${libidn.dev}" else "--without-libidn" )
]
++ stdenv.lib.optional c-aresSupport "--enable-ares=${c-ares}";
CXX = "g++";
CXXCPP = "g++ -E";
postInstall = ''
moveToOutput bin/curl-config "$dev"
sed '/^dependency_libs/s|${libssh2.dev}|${libssh2.out}|' -i "$out"/lib/*.la
moveToOutput lib/ "$out"
rm $out/lib/libcurl.la
ln -s $out/lib/libcurl.so.4.4.0 $out/lib/libcurl.so.3
'';
crossAttrs = {
# We should refer to the cross built openssl
# For the 'urandom', maybe it should be a cross-system option
configureFlags = [
( if sslSupport then "--with-ssl=${openssl.crossDrv}" else "--without-ssl" )
"--with-random /dev/urandom"
];
};
passthru = {
inherit sslSupport openssl;
};
meta = with stdenv.lib; {
description = "A command line tool for transferring files with URL syntax";
homepage = http://curl.haxx.se/;
maintainers = with maintainers; [ lovek323 ];
platforms = platforms.all;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment