2022-06-16 17:23:12 +00:00
|
|
|
{ lib, stdenv, fetchurl, pkg-config, perl, nixosTests
|
2022-07-18 16:21:45 +00:00
|
|
|
, brotliSupport ? false, brotli
|
|
|
|
, c-aresSupport ? false, c-ares
|
|
|
|
, gnutlsSupport ? false, gnutls
|
|
|
|
, gsaslSupport ? false, gsasl
|
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))
|
2022-07-18 16:21:45 +00:00
|
|
|
), libkrb5
|
|
|
|
, http2Support ? true, nghttp2
|
|
|
|
, http3Support ? false, nghttp3, ngtcp2
|
|
|
|
, idnSupport ? false, libidn2
|
|
|
|
, ldapSupport ? false, openldap
|
|
|
|
, opensslSupport ? zlibSupport, openssl
|
|
|
|
, pslSupport ? false, libpsl
|
|
|
|
, rtmpSupport ? false, rtmpdump
|
|
|
|
, scpSupport ? zlibSupport && !stdenv.isSunOS && !stdenv.isCygwin, libssh2
|
|
|
|
, wolfsslSupport ? false, wolfssl
|
|
|
|
, zlibSupport ? true, zlib
|
|
|
|
, zstdSupport ? false, zstd
|
2022-05-18 14:49:53 +00:00
|
|
|
|
|
|
|
# for passthru.tests
|
|
|
|
, coeurl
|
|
|
|
, curlpp
|
|
|
|
, haskellPackages
|
|
|
|
, ocamlPackages
|
|
|
|
, phpExtensions
|
|
|
|
, python3
|
2022-08-12 12:06:08 +00:00
|
|
|
, tests
|
|
|
|
, fetchpatch
|
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
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-06-02 18:00:15 +00:00
|
|
|
pname = "curl";
|
2022-09-30 11:47:45 +00:00
|
|
|
version = "7.85.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
urls = [
|
2022-08-12 12:06:08 +00:00
|
|
|
"https://curl.haxx.se/download/curl-${finalAttrs.version}.tar.bz2"
|
|
|
|
"https://github.com/curl/curl/releases/download/curl-${finalAttrs.version}/curl-${finalAttrs.version}.tar.bz2"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
2022-09-30 11:47:45 +00:00
|
|
|
sha256 = "sha256-IafoNijulhZKwrNv9r+Z1GfHsLYhwffjF9jw2WARU5w=";
|
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-09-30 11:47:45 +00:00
|
|
|
];
|
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.
|
2022-05-18 14:49:53 +00:00
|
|
|
"--without-ca-bundle"
|
2022-04-27 09:35:20 +00:00
|
|
|
"--without-ca-path"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
CXX = "${stdenv.cc.targetPrefix}c++";
|
|
|
|
CXXCPP = "${stdenv.cc.targetPrefix}c++ -E";
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# takes 14 minutes on a 24 core and because many other packages depend on curl
|
|
|
|
# they cannot be run concurrently and are a bottleneck
|
|
|
|
# tests are available in passthru.tests.withCheck
|
|
|
|
doCheck = false;
|
2022-05-18 14:49:53 +00:00
|
|
|
preCheck = ''
|
|
|
|
patchShebangs tests/
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# bad interaction with sandbox if enabled?
|
|
|
|
rm tests/data/test1453
|
|
|
|
rm tests/data/test1086
|
|
|
|
'' + lib.optionalString stdenv.hostPlatform.isMusl ''
|
|
|
|
# different resolving behaviour?
|
|
|
|
rm tests/data/test1592
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
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 ''
|
2022-06-16 17:23:12 +00:00
|
|
|
ln $out/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libcurl-gnutls${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
ln $out/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libcurl-gnutls${stdenv.hostPlatform.extensions.sharedLibrary}.4
|
|
|
|
ln $out/lib/libcurl${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libcurl-gnutls${stdenv.hostPlatform.extensions.sharedLibrary}.4.4.0
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
passthru = let
|
|
|
|
useThisCurl = attr: attr.override { curl = finalAttrs.finalPackage; };
|
|
|
|
in {
|
2021-12-06 16:07:01 +00:00
|
|
|
inherit opensslSupport openssl;
|
2022-05-18 14:49:53 +00:00
|
|
|
tests = {
|
2022-08-12 12:06:08 +00:00
|
|
|
withCheck = finalAttrs.finalPackage.overrideAttrs (_: { doCheck = true; });
|
|
|
|
fetchpatch = tests.fetchpatch.simple.override { fetchpatch = fetchpatch.override { fetchurl = useThisCurl fetchurl; }; };
|
|
|
|
curlpp = useThisCurl curlpp;
|
|
|
|
coeurl = useThisCurl coeurl;
|
|
|
|
haskell-curl = useThisCurl haskellPackages.curl;
|
|
|
|
ocaml-curly = useThisCurl ocamlPackages.curly;
|
|
|
|
pycurl = useThisCurl python3.pkgs.pycurl;
|
|
|
|
php-curl = useThisCurl phpExtensions.curl;
|
|
|
|
# error: attribute 'override' missing
|
2022-06-16 17:23:12 +00:00
|
|
|
# Additional checking with support http3 protocol.
|
2022-08-12 12:06:08 +00:00
|
|
|
# nginx-http3 = useThisCurl nixosTests.nginx-http3;
|
|
|
|
nginx-http3 = nixosTests.nginx-http3;
|
2022-05-18 14:49:53 +00:00
|
|
|
};
|
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
|
|
|
};
|
2022-08-12 12:06:08 +00:00
|
|
|
})
|