From 93a64793df33b1b6a0d6a876ac1c1692b6f44133 Mon Sep 17 00:00:00 2001 From: Mats Date: Fri, 15 Aug 2025 18:03:07 +0200 Subject: [PATCH 1/2] curl-impersonate-chrome: 0.8.0 -> 1.2.0 --- .../cu/curl-impersonate/chrome/default.nix | 65 ++++++++++--------- .../cu/curl-impersonate/chrome/deps.nix | 22 +++++-- .../chrome/disable-building-docs.patch | 20 ------ .../cu/curl-impersonate/chrome/update.sh | 38 +++++++++-- 4 files changed, 80 insertions(+), 65 deletions(-) delete mode 100644 pkgs/by-name/cu/curl-impersonate/chrome/disable-building-docs.patch diff --git a/pkgs/by-name/cu/curl-impersonate/chrome/default.nix b/pkgs/by-name/cu/curl-impersonate/chrome/default.nix index efdd2c69fba3..e5d699a68dd1 100644 --- a/pkgs/by-name/cu/curl-impersonate/chrome/default.nix +++ b/pkgs/by-name/cu/curl-impersonate/chrome/default.nix @@ -13,6 +13,7 @@ python3, ninja, perl, + pkg-config, autoconf, automake, libtool, @@ -24,7 +25,7 @@ }: stdenv.mkDerivation rec { pname = "curl-impersonate-chrome"; - version = "0.8.0"; + version = "1.2.0"; outputs = [ "out" @@ -32,14 +33,12 @@ stdenv.mkDerivation rec { ]; src = fetchFromGitHub { - owner = "yifeikong"; + owner = "lexiforest"; repo = "curl-impersonate"; rev = "v${version}"; - hash = "sha256-m6zeQUL+yBh3ixS+crbJWHX5TLa61A/3oqMz5UVELso="; + hash = "sha256-tAQdTRGAOD2rpLZvoLQ2YL0wrohXEcmChMZBvYjsMhE="; }; - patches = [ ./disable-building-docs.patch ]; - # Disable blanket -Werror to fix build on `gcc-13` related to minor # warnings on `boringssl`. env.NIX_CFLAGS_COMPILE = "-Wno-error"; @@ -62,6 +61,7 @@ stdenv.mkDerivation rec { python3.pythonOnBuildForHost.pkgs.gyp ninja perl + pkg-config autoconf automake libtool @@ -82,9 +82,9 @@ stdenv.mkDerivation rec { "--with-ca-path=${cacert}/etc/ssl/certs" ]; - buildFlags = [ "chrome-build" ]; - checkTarget = "chrome-checkbuild"; - installTargets = [ "chrome-install" ]; + buildFlags = [ "build" ]; + checkTarget = "checkbuild"; + installTargets = [ "install" ]; doCheck = true; @@ -117,6 +117,11 @@ stdenv.mkDerivation rec { popd ''; + postPatch = '' + substituteInPlace Makefile.in \ + --replace-fail "-lc++" "-lstdc++" + ''; + preConfigure = '' export GOCACHE=$TMPDIR/go-cache export GOPATH=$TMPDIR/go @@ -129,7 +134,7 @@ stdenv.mkDerivation rec { postInstall = '' # Remove vestigial *-config script - rm $out/bin/curl-impersonate-chrome-config + rm $out/bin/curl-impersonate-config # Patch all shebangs of installed scripts patchShebangs $out/bin @@ -138,23 +143,13 @@ stdenv.mkDerivation rec { make -C curl-*/include install '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' - # Build and install completions for each curl binary + # Patch completion names + substituteInPlace curl-*/scripts/Makefile \ + --replace-fail "_curl" "_curl-impersonate" \ + --replace-fail "curl.fish" "curl-impersonate.fish" - # Patch in correct binary name and alias it to all scripts - perl curl-*/scripts/completion.pl --curl $out/bin/curl-impersonate-chrome --shell zsh >$TMPDIR/curl-impersonate-chrome.zsh - substituteInPlace $TMPDIR/curl-impersonate-chrome.zsh \ - --replace-fail \ - '#compdef curl' \ - "#compdef curl-impersonate-chrome$(find $out/bin -name 'curl_*' -printf ' %f=curl-impersonate-chrome')" - - perl curl-*/scripts/completion.pl --curl $out/bin/curl-impersonate-chrome --shell fish >$TMPDIR/curl-impersonate-chrome.fish - substituteInPlace $TMPDIR/curl-impersonate-chrome.fish \ - --replace-fail \ - '--command curl' \ - "--command curl-impersonate-chrome$(find $out/bin -name 'curl_*' -printf ' --command %f')" - - # Install zsh and fish completions - installShellCompletion $TMPDIR/curl-impersonate-chrome.{zsh,fish} + # Install completions + make -C curl-*/scripts install ''; preFixup = @@ -163,10 +158,10 @@ stdenv.mkDerivation rec { in '' # If libnssckbi.so is needed, link libnssckbi.so without needing nss in closure - if grep -F nssckbi $out/lib/libcurl-impersonate-*${libext} &>/dev/null; then + if grep -F nssckbi $out/lib/libcurl-impersonate${libext} &>/dev/null; then ln -s ${p11-kit}/lib/pkcs11/p11-kit-trust${libext} $out/lib/libnssckbi${libext} ${lib.optionalString stdenv.hostPlatform.isElf '' - patchelf --add-needed libnssckbi${libext} $out/lib/libcurl-impersonate-*${libext} + patchelf --add-needed libnssckbi${libext} $out/lib/libcurl-impersonate${libext} ''} fi ''; @@ -178,12 +173,18 @@ stdenv.mkDerivation rec { updateScript = ./update.sh; + # Find the correct boringssl source file + boringssl-source = builtins.head ( + lib.mapAttrsToList (_: file: file) ( + lib.filterAttrs (name: _: lib.strings.hasPrefix "boringssl-" name) passthru.deps + ) + ); boringssl-go-modules = (buildGoModule { - inherit (passthru.deps."boringssl.zip") name; + inherit (passthru.boringssl-source) name; - src = passthru.deps."boringssl.zip"; - vendorHash = "sha256-oKlwh+Oup3lVgqgq42vY3iLg62VboF9N565yK2W0XxI="; + src = passthru.boringssl-source; + vendorHash = "sha256-HepiJhj7OsV7iQHlM2yi5BITyAM04QqWRX28Rj7sRKk="; nativeBuildInputs = [ unzip ]; @@ -193,13 +194,13 @@ stdenv.mkDerivation rec { meta = { description = "Special build of curl that can impersonate Chrome & Firefox"; - homepage = "https://github.com/yifeikong/curl-impersonate"; + homepage = "https://github.com/lexiforest/curl-impersonate"; license = with lib.licenses; [ curl mit ]; maintainers = with lib.maintainers; [ ggg ]; platforms = lib.platforms.unix; - mainProgram = "curl-impersonate-chrome"; + mainProgram = "curl-impersonate"; }; } diff --git a/pkgs/by-name/cu/curl-impersonate/chrome/deps.nix b/pkgs/by-name/cu/curl-impersonate/chrome/deps.nix index 24669769556a..3cf8d218c719 100644 --- a/pkgs/by-name/cu/curl-impersonate/chrome/deps.nix +++ b/pkgs/by-name/cu/curl-impersonate/chrome/deps.nix @@ -2,9 +2,9 @@ { fetchurl }: { - "curl-8_7_1.tar.gz" = fetchurl { - url = "https://github.com/curl/curl/archive/curl-8_7_1.tar.gz"; - hash = "sha256-DkbIVvUXYCw0e7X+W3MXT47nmLyH8alyNclXYfdfzCg="; + "curl-8_15_0.tar.gz" = fetchurl { + url = "https://github.com/curl/curl/archive/curl-8_15_0.tar.gz"; + hash = "sha256-KTfK3eAHqjpSoXwhrJFT6gVHAPN5JtHZZgK/B+iIyEc="; }; "brotli-1.1.0.tar.gz" = fetchurl { @@ -12,13 +12,23 @@ hash = "sha256-5yCmyilCi4A/StFlNxdx9TmPq6OX7fZ3iDehhZnqE/8="; }; - "boringssl.zip" = fetchurl { - url = "https://github.com/google/boringssl/archive/d24a38200fef19150eef00cad35b138936c08767.zip"; - hash = "sha256-tzAAwL70VAyUEOZZ86ql+RgXsw4DZhkvW5l0d1eVVHU="; + "boringssl-673e61fc215b178a90c0e67858bbf162c8158993.zip" = fetchurl { + url = "https://github.com/google/boringssl/archive/673e61fc215b178a90c0e67858bbf162c8158993.zip"; + hash = "sha256-7bfWHo3j95EHAXJyPuQfvFUPtVCAzbGHu0oF5g4FmiI="; }; "nghttp2-1.63.0.tar.bz2" = fetchurl { url = "https://github.com/nghttp2/nghttp2/releases/download/v1.63.0/nghttp2-1.63.0.tar.bz2"; hash = "sha256-YHsXRVTSKoKLxTLR1zT+D3KbXV7SB/LxLpamLoPynFU="; }; + + "ngtcp2-1.11.0.tar.bz2" = fetchurl { + url = "https://github.com/ngtcp2/ngtcp2/releases/download/v1.11.0/ngtcp2-1.11.0.tar.bz2"; + hash = "sha256-122s6G/Docj84codTLsf3pu6k81fKGEdVbypukPjF7w="; + }; + + "nghttp3-1.9.0.tar.bz2" = fetchurl { + url = "https://github.com/ngtcp2/nghttp3/releases/download/v1.9.0/nghttp3-1.9.0.tar.bz2"; + hash = "sha256-TTCmjxfnKhOStghdr6qfxzLaHX0m7sVUuyFnCDMvzxo="; + }; } diff --git a/pkgs/by-name/cu/curl-impersonate/chrome/disable-building-docs.patch b/pkgs/by-name/cu/curl-impersonate/chrome/disable-building-docs.patch deleted file mode 100644 index ba7a8990ec1a..000000000000 --- a/pkgs/by-name/cu/curl-impersonate/chrome/disable-building-docs.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 5366ca35b3d20ef962ccf54399cc44f523d803be Mon Sep 17 00:00:00 2001 -From: GGG -Date: Mon, 5 Aug 2024 04:19:29 -0300 -Subject: [PATCH] Disable building docs ---- - Makefile.in | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/Makefile.in b/Makefile.in -index 41d7324..b1f5ec6 100644 ---- a/Makefile.in -+++ b/Makefile.in -@@ -249,6 +249,7 @@ $(CURL_VERSION)/.chrome: $(chrome_libs) $(CURL_VERSION).tar.gz $(CURL_VERSION)/. - # (for cross compilation), then pass it on to curl. - { \ - config_flags="--prefix=@prefix@"; \ -+ config_flags="$$config_flags --disable-manual"; \ - config_flags="$$config_flags --with-nghttp2=$(nghttp2_install_dir)"; \ - config_flags="$$config_flags --with-brotli=$(brotli_install_dir)"; \ - config_flags="$$config_flags --with-openssl=$(boringssl_install_dir)"; \ diff --git a/pkgs/by-name/cu/curl-impersonate/chrome/update.sh b/pkgs/by-name/cu/curl-impersonate/chrome/update.sh index afda6e3fbf53..31f8349eb702 100755 --- a/pkgs/by-name/cu/curl-impersonate/chrome/update.sh +++ b/pkgs/by-name/cu/curl-impersonate/chrome/update.sh @@ -33,11 +33,25 @@ findpath() { } getvar() { - echo "$2" | grep -F "$1" | sed -e 's/:=/:/g' | cut -d: -f2- | stripwhitespace + echo "$2" | grep -F "$1 " | sed -e 's/:=/:/g' | cut -d: -f2- | stripwhitespace +} + +evalvar() { + local out="$(getvar "$1" "$2")" + + # Replace $(VAR) within variables with other variables + while [[ "$out" =~ (\$\(([A-Za-z_][A-Za-z0-9_]*)\)) ]]; do + local match="${BASH_REMATCH[1]}" + local var="${BASH_REMATCH[2]}" + local value="$(getvar "$var" "$2")" + out="${out//$match/$value}" + done + + echo $out } attr="${UPDATE_NIX_ATTR_PATH:-curl-impersonate-chrome}" -version="$(curl -sSL "https://api.github.com/repos/yifeikong/curl-impersonate/releases/latest" | jq -r .tag_name | sed -e 's/^v//')" +version="$(curl -sSL "https://api.github.com/repos/lexiforest/curl-impersonate/releases/latest" | jq -r .tag_name | sed -e 's/^v//')" pkgpath="$(findpath "$attr")" @@ -48,7 +62,7 @@ if [ "$updated" -eq 0 ]; then exit 0 fi -vars="$(curl -sSL "https://github.com/yifeikong/curl-impersonate/raw/v$version/Makefile.in" | grep '^ *[^ ]*_\(VERSION\|URL\|COMMIT\) *:=')" +vars="$(curl -sSL "https://github.com/lexiforest/curl-impersonate/raw/v$version/Makefile.in" | grep '^ *[^ ]*_\(VERSION\|URL\|COMMIT\) *:=')" # TODO: Fix hash for curl. cat >"$(dirname "$pkgpath")"/deps.nix <"$(dirname "$pkgpath")"/deps.nix < Date: Fri, 15 Aug 2025 18:04:39 +0200 Subject: [PATCH 2/2] python3Packages.curl-cffi: link to correct curl-impersonate lib --- pkgs/development/python-modules/curl-cffi/use-system-libs.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/python-modules/curl-cffi/use-system-libs.patch b/pkgs/development/python-modules/curl-cffi/use-system-libs.patch index 1d044873e461..3dcec2e14c7c 100644 --- a/pkgs/development/python-modules/curl-cffi/use-system-libs.patch +++ b/pkgs/development/python-modules/curl-cffi/use-system-libs.patch @@ -17,7 +17,7 @@ index b705a0d..9bfcaab 100644 - libraries=get_curl_libraries(), - extra_objects=get_curl_archives(), - library_dirs=[arch["libdir"]], -+ libraries=["curl-impersonate-chrome"], ++ libraries=["curl-impersonate"], source_extension=".c", include_dirs=[ str(root_dir / "include"),