From 1e09d4edbbfc4070a3d5d86dd39feade38d0021e Mon Sep 17 00:00:00 2001 From: Genevieve Date: Tue, 19 Mar 2024 19:18:52 -0400 Subject: [PATCH] ada-url: init at 2.7.7 Based on https://github.com/NixOS/nixpkgs/pull/227030 The patch is included since I ran into a roadblock due to how ada implemented cpm (cmake package manager). There are other packages in nixpkgs which work around it (e.g., poac) but those package upstreams gate their downloads on a conditional: ``` if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) file(DOWNLOAD ... ``` I patched ada to reproduce this behavior so it can build in the sandbox. --- pkgs/by-name/ad/ada-url/conditional-dl.patch | 20 +++++++ pkgs/by-name/ad/ada-url/package.nix | 61 ++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 pkgs/by-name/ad/ada-url/conditional-dl.patch create mode 100644 pkgs/by-name/ad/ada-url/package.nix diff --git a/pkgs/by-name/ad/ada-url/conditional-dl.patch b/pkgs/by-name/ad/ada-url/conditional-dl.patch new file mode 100644 index 000000000000000..8c62b073ba67cdf --- /dev/null +++ b/pkgs/by-name/ad/ada-url/conditional-dl.patch @@ -0,0 +1,20 @@ +diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake +index ad6b74a8..079eed46 100644 +--- a/cmake/CPM.cmake ++++ b/cmake/CPM.cmake +@@ -16,9 +16,11 @@ endif() + # Expand relative path. This is important if the provided path contains a tilde (~) + get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) + +-file(DOWNLOAD +- https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake +- ${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM} +-) ++if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) ++ file(DOWNLOAD ++ https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake ++ ${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM} ++ ) ++endif() + + include(${CPM_DOWNLOAD_LOCATION}) diff --git a/pkgs/by-name/ad/ada-url/package.nix b/pkgs/by-name/ad/ada-url/package.nix new file mode 100644 index 000000000000000..5d366873eca7071 --- /dev/null +++ b/pkgs/by-name/ad/ada-url/package.nix @@ -0,0 +1,61 @@ +{ + lib, + fetchFromGitHub, + stdenv, + cpm-cmake, + simdjson, + cmake, + cxxopts, +}: + +let + googletest = fetchFromGitHub { + owner = "google"; + repo = "googletest"; + rev = "v1.14.0"; + hash = "sha256-t0RchAHTJbuI5YW4uyBPykTvcjy90JW9AOPNjIhwh6U="; + }; + googlebenchmark = fetchFromGitHub { + owner = "google"; + repo = "benchmark"; + rev = "v1.6.0"; + hash = "sha256-EAJk3JhLdkuGKRMtspTLejck8doWPd7Z0Lv/Mvf3KFY="; + }; + pname = "ada"; + version = "2.7.7"; +in +stdenv.mkDerivation rec { + inherit pname version; + src = fetchFromGitHub { + owner = "ada-url"; + repo = pname; + rev = "v${version}"; + hash = "sha256-eh/tOwU+sU/8FYYuRE7DL1v1Fp6bNFWneLtGG0wsWgA="; + }; + + patches = [ ./conditional-dl.patch ]; + + preConfigure = '' + mkdir -p ${placeholder "out"}/share/cpm + cp ${cpm-cmake}/share/cpm/CPM.cmake ${placeholder "out"}/share/cpm/CPM_0.38.6.cmake + ''; + + cmakeFlags = [ + "-DCPM_SOURCE_CACHE=${placeholder "out"}/share" + "-DFETCHCONTENT_SOURCE_DIR_SIMDJSON=${simdjson.src}" + "-DFETCHCONTENT_SOURCE_DIR_GTEST=${googletest}" + "-DFETCHCONTENT_SOURCE_DIR_BENCHMARK=${googlebenchmark}" + "-DBUILD_SHARED_LIBS=ON" + ]; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ cxxopts ]; + meta = with lib; { + homepage = "https://www.ada-url.com/"; + description = "WHATWG-compliant and fast URL parser written in modern C++"; + license = licenses.asl20; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ genevieve-me ]; + }; +}