2022-01-26 04:04:25 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, perl
|
|
|
|
, brotliSupport ? false, brotli ? null
|
|
|
|
, c-aresSupport ? false, c-ares ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
, gnutlsSupport ? false, gnutls ? null
|
2022-01-26 04:04:25 +00:00
|
|
|
, gsaslSupport ? false, gsasl ? null
|
2021-09-18 10:52:07 +00:00
|
|
|
, gssSupport ? with stdenv.hostPlatform; (
|
2021-05-28 09:39:13 +00:00
|
|
|
!isWindows &&
|
2021-09-18 10:52:07 +00:00
|
|
|
# disable gss becuase of: undefined reference to `k5_bcmp'
|
2021-05-28 09:39:13 +00:00
|
|
|
# a very sad story re static: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439039
|
|
|
|
!isStatic &&
|
|
|
|
# the "mig" tool does not configure its compiler correctly. This could be
|
|
|
|
# fixed in mig, but losing gss support on cross compilation to darwin is
|
|
|
|
# not worth the effort.
|
|
|
|
!(isDarwin && (stdenv.buildPlatform != stdenv.hostPlatform))
|
|
|
|
), libkrb5 ? null
|
2022-01-26 04:04:25 +00:00
|
|
|
, http2Support ? true, nghttp2 ? null
|
|
|
|
, http3Support ? false, nghttp3, ngtcp2 ? null
|
|
|
|
, idnSupport ? false, libidn2 ? null
|
|
|
|
, ldapSupport ? false, openldap ? null
|
|
|
|
, opensslSupport ? zlibSupport, openssl ? null
|
|
|
|
, pslSupport ? false, libpsl ? null
|
|
|
|
, rtmpSupport ? false, rtmpdump ? null
|
|
|
|
, scpSupport ? zlibSupport && !stdenv.isSunOS && !stdenv.isCygwin, libssh2 ? null
|
|
|
|
, wolfsslSupport ? false, wolfssl ? null
|
|
|
|
, zlibSupport ? true, zlib ? null
|
|
|
|
, zstdSupport ? false, zstd ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
# Note: this package is used for bootstrapping fetchurl, and thus
|
|
|
|
# cannot use fetchpatch! All mutable patches (generated by GitHub or
|
|
|
|
# cgit) that are needed here should be included directly in Nixpkgs as
|
|
|
|
# files.
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
assert !(gnutlsSupport && opensslSupport);
|
2020-04-24 23:36:52 +00:00
|
|
|
assert !(gnutlsSupport && wolfsslSupport);
|
2021-12-06 16:07:01 +00:00
|
|
|
assert !(opensslSupport && wolfsslSupport);
|
2020-04-24 23:36:52 +00:00
|
|
|
assert brotliSupport -> brotli != null;
|
2022-01-26 04:04:25 +00:00
|
|
|
assert c-aresSupport -> c-ares != null;
|
|
|
|
assert gnutlsSupport -> gnutls != null;
|
|
|
|
assert gsaslSupport -> gsasl != null;
|
2020-04-24 23:36:52 +00:00
|
|
|
assert gssSupport -> libkrb5 != null;
|
2022-01-26 04:04:25 +00:00
|
|
|
assert http2Support -> nghttp2 != null;
|
|
|
|
assert http3Support -> nghttp3 != null;
|
|
|
|
assert http3Support -> ngtcp2 != null;
|
|
|
|
assert idnSupport -> libidn2 != null;
|
|
|
|
assert ldapSupport -> openldap != null;
|
|
|
|
assert opensslSupport -> openssl != null;
|
|
|
|
assert pslSupport -> libpsl !=null;
|
|
|
|
assert rtmpSupport -> rtmpdump !=null;
|
|
|
|
assert scpSupport -> libssh2 != null;
|
|
|
|
assert wolfsslSupport -> wolfssl != null;
|
|
|
|
assert zlibSupport -> zlib != null;
|
|
|
|
assert zstdSupport -> zstd != null;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2020-06-02 18:00:15 +00:00
|
|
|
pname = "curl";
|
2022-04-15 01:41:22 +00:00
|
|
|
version = "7.82.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
urls = [
|
2020-06-02 18:00:15 +00:00
|
|
|
"https://curl.haxx.se/download/${pname}-${version}.tar.bz2"
|
|
|
|
"https://github.com/curl/curl/releases/download/${lib.replaceStrings ["."] ["_"] pname}-${version}/${pname}-${version}.tar.bz2"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
2022-04-15 01:41:22 +00:00
|
|
|
sha256 = "sha256-RtmgQAozQI/ZkncLBKRKdDSzA28ugImsKLV1c9WdNx8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
patches = [
|
2021-12-06 16:07:01 +00:00
|
|
|
./7.79.1-darwin-no-systemconfiguration.patch
|
2022-04-15 01:41:22 +00:00
|
|
|
./7.82.0-openssl-fix-CN-check.patch
|
2021-06-28 23:13:55 +00:00
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
outputs = [ "bin" "dev" "out" "man" "devdoc" ];
|
|
|
|
separateDebugInfo = stdenv.isLinux;
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
strictDeps = true;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ pkg-config perl ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# Zlib and OpenSSL must be propagated because `libcurl.la' contains
|
|
|
|
# "-lz -lssl", which aren't necessary direct build inputs of
|
|
|
|
# applications that use Curl.
|
2021-01-15 22:18:51 +00:00
|
|
|
propagatedBuildInputs = with lib;
|
2022-01-26 04:04:25 +00:00
|
|
|
optional brotliSupport brotli ++
|
|
|
|
optional c-aresSupport c-ares ++
|
|
|
|
optional gnutlsSupport gnutls ++
|
|
|
|
optional gsaslSupport gsasl ++
|
|
|
|
optional gssSupport libkrb5 ++
|
2020-04-24 23:36:52 +00:00
|
|
|
optional http2Support nghttp2 ++
|
2022-01-26 04:04:25 +00:00
|
|
|
optionals http3Support [ nghttp3 ngtcp2 ] ++
|
|
|
|
optional idnSupport libidn2 ++
|
2020-04-24 23:36:52 +00:00
|
|
|
optional ldapSupport openldap ++
|
2021-12-06 16:07:01 +00:00
|
|
|
optional opensslSupport openssl ++
|
2022-01-26 04:04:25 +00:00
|
|
|
optional pslSupport libpsl ++
|
|
|
|
optional rtmpSupport rtmpdump ++
|
2020-04-24 23:36:52 +00:00
|
|
|
optional scpSupport libssh2 ++
|
2022-01-26 04:04:25 +00:00
|
|
|
optional wolfsslSupport wolfssl ++
|
|
|
|
optional zlibSupport zlib ++
|
|
|
|
optional zstdSupport zstd;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# for the second line see https://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 = [
|
2022-01-26 04:04:25 +00:00
|
|
|
# Build without manual
|
|
|
|
"--disable-manual"
|
|
|
|
(lib.enableFeature c-aresSupport "ares")
|
|
|
|
(lib.enableFeature ldapSupport "ldap")
|
|
|
|
(lib.enableFeature ldapSupport "ldaps")
|
2020-04-24 23:36:52 +00:00
|
|
|
# The build fails when using wolfssl with --with-ca-fallback
|
2021-09-18 10:52:07 +00:00
|
|
|
(lib.withFeature (!wolfsslSupport) "ca-fallback")
|
2022-01-26 04:04:25 +00:00
|
|
|
(lib.withFeature http3Support "nghttp3")
|
|
|
|
(lib.withFeature http3Support "ngtcp2")
|
|
|
|
(lib.withFeature rtmpSupport "librtmp")
|
|
|
|
(lib.withFeature zstdSupport "zstd")
|
|
|
|
(lib.withFeatureAs brotliSupport "brotli" (lib.getDev brotli))
|
2021-12-26 17:43:05 +00:00
|
|
|
(lib.withFeatureAs gnutlsSupport "gnutls" (lib.getDev gnutls))
|
2022-01-26 04:04:25 +00:00
|
|
|
(lib.withFeatureAs idnSupport "libidn2" (lib.getDev libidn2))
|
|
|
|
(lib.withFeatureAs opensslSupport "openssl" (lib.getDev openssl))
|
2021-12-26 17:43:05 +00:00
|
|
|
(lib.withFeatureAs scpSupport "libssh2" (lib.getDev libssh2))
|
2022-01-26 04:04:25 +00:00
|
|
|
(lib.withFeatureAs wolfsslSupport "wolfssl" (lib.getDev wolfssl))
|
2020-04-24 23:36:52 +00:00
|
|
|
]
|
2021-12-26 17:43:05 +00:00
|
|
|
++ lib.optional gssSupport "--with-gssapi=${lib.getDev libkrb5}"
|
2020-04-24 23:36:52 +00:00
|
|
|
# For the 'urandom', maybe it should be a cross-system option
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform)
|
2020-04-24 23:36:52 +00:00
|
|
|
"--with-random=/dev/urandom"
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isWindows [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--disable-shared"
|
|
|
|
"--enable-static"
|
2022-04-27 09:35:20 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
# Disable default CA bundle, use NIX_SSL_CERT_FILE or fallback to nss-cacert from the default profile.
|
|
|
|
# Without this curl might detect /etc/ssl/cert.pem at build time on macOS, causing curl to ignore NIX_SSL_CERT_FILE.
|
|
|
|
# https://github.com/curl/curl/issues/8696 - fallback is not supported by HTTP3
|
|
|
|
(if http3Support then "--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt" else "--without-ca-bundle")
|
|
|
|
"--without-ca-path"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
CXX = "${stdenv.cc.targetPrefix}c++";
|
|
|
|
CXXCPP = "${stdenv.cc.targetPrefix}c++ -E";
|
|
|
|
|
|
|
|
doCheck = false; # expensive, fails
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
moveToOutput bin/curl-config "$dev"
|
|
|
|
|
|
|
|
# Install completions
|
|
|
|
make -C scripts install
|
2021-01-15 22:18:51 +00:00
|
|
|
'' + lib.optionalString scpSupport ''
|
2021-12-26 17:43:05 +00:00
|
|
|
sed '/^dependency_libs/s|${lib.getDev libssh2}|${lib.getLib libssh2}|' -i "$out"/lib/*.la
|
2021-01-15 22:18:51 +00:00
|
|
|
'' + lib.optionalString gnutlsSupport ''
|
2020-04-24 23:36:52 +00:00
|
|
|
ln $out/lib/libcurl.so $out/lib/libcurl-gnutls.so
|
|
|
|
ln $out/lib/libcurl.so $out/lib/libcurl-gnutls.so.4
|
|
|
|
ln $out/lib/libcurl.so $out/lib/libcurl-gnutls.so.4.4.0
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
2021-12-06 16:07:01 +00:00
|
|
|
inherit opensslSupport openssl;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A command line tool for transferring files with URL syntax";
|
2021-12-26 17:43:05 +00:00
|
|
|
homepage = "https://curl.se/";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.curl;
|
2020-06-02 18:00:15 +00:00
|
|
|
maintainers = with maintainers; [ lovek323 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.all;
|
2021-09-18 10:52:07 +00:00
|
|
|
# Fails to link against static brotli or gss
|
|
|
|
broken = stdenv.hostPlatform.isStatic && (brotliSupport || gssSupport);
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|