From e19d28db2a9e4564d1a4ef1a9f1a464bce788756 Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Wed, 19 Jun 2024 11:49:17 +0300 Subject: [PATCH 1/2] re2: use ICU, enable tests, refactor --- pkgs/development/libraries/re2/default.nix | 45 ++++++++-------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/pkgs/development/libraries/re2/default.nix b/pkgs/development/libraries/re2/default.nix index 7c2f75f9f909..910a0a0f1921 100644 --- a/pkgs/development/libraries/re2/default.nix +++ b/pkgs/development/libraries/re2/default.nix @@ -3,22 +3,25 @@ , fetchFromGitHub , cmake , ninja +, gtest +, gbenchmark +, abseil-cpp +, icu , chromium , grpc -, haskellPackages , mercurial , python3Packages -, abseil-cpp +, haskellPackages }: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "re2"; version = "2024-06-01"; src = fetchFromGitHub { owner = "google"; repo = "re2"; - rev = version; + rev = finalAttrs.version; hash = "sha256-iQETsjdIFcYM5I/W8ytvV3z/4va6TaZ/+KkSjb8CtF0="; }; @@ -26,36 +29,20 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake ninja ]; - propagatedBuildInputs = [ abseil-cpp ]; + buildInputs = lib.optionals finalAttrs.doCheck [ gtest gbenchmark ]; - postPatch = '' - substituteInPlace re2Config.cmake.in \ - --replace "\''${PACKAGE_PREFIX_DIR}/" "" - ''; + propagatedBuildInputs = [ abseil-cpp icu ]; - # Needed for case-insensitive filesystems (i.e. MacOS) because a file named - # BUILD already exists. - cmakeBuildDir = "build_dir"; - - cmakeFlags = lib.optional (!stdenv.hostPlatform.isStatic) "-DBUILD_SHARED_LIBS:BOOL=ON"; - - # This installs a pkg-config definition. - postInstall = '' - pushd "$src" - make common-install prefix="$dev" SED_INPLACE="sed -i" - popd - ''; + cmakeFlags = [ + (lib.cmakeBool "RE2_BUILD_TESTING" finalAttrs.doCheck) + (lib.cmakeBool "RE2_USE_ICU" true) + ] ++ lib.optional (!stdenv.hostPlatform.isStatic) (lib.cmakeBool "BUILD_SHARED_LIBS" true); doCheck = true; passthru.tests = { - inherit - chromium - grpc - mercurial; - inherit (python3Packages) - fb-re2 - google-re2; + inherit chromium grpc mercurial; + inherit (python3Packages) fb-re2 google-re2; haskell-re2 = haskellPackages.re2; }; @@ -71,4 +58,4 @@ stdenv.mkDerivation rec { maintainers = with maintainers; [ azahi networkexception ]; platforms = platforms.all; }; -} +}) From fe4760b753a8cbaf05fb2c0567d1b8be75a6b8eb Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Wed, 19 Jun 2024 17:52:56 +0300 Subject: [PATCH 2/2] re2: apply nixfmt and sort inputs --- pkgs/development/libraries/re2/default.nix | 54 ++++++++++++++-------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/pkgs/development/libraries/re2/default.nix b/pkgs/development/libraries/re2/default.nix index 910a0a0f1921..09d2f7539f15 100644 --- a/pkgs/development/libraries/re2/default.nix +++ b/pkgs/development/libraries/re2/default.nix @@ -1,17 +1,18 @@ -{ lib -, stdenv -, fetchFromGitHub -, cmake -, ninja -, gtest -, gbenchmark -, abseil-cpp -, icu -, chromium -, grpc -, mercurial -, python3Packages -, haskellPackages +{ + abseil-cpp, + chromium, + cmake, + fetchFromGitHub, + gbenchmark, + grpc, + gtest, + haskellPackages, + icu, + lib, + mercurial, + ninja, + python3Packages, + stdenv, }: stdenv.mkDerivation (finalAttrs: { @@ -25,13 +26,25 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-iQETsjdIFcYM5I/W8ytvV3z/4va6TaZ/+KkSjb8CtF0="; }; - outputs = [ "out" "dev" ]; + outputs = [ + "out" + "dev" + ]; - nativeBuildInputs = [ cmake ninja ]; + nativeBuildInputs = [ + cmake + ninja + ]; - buildInputs = lib.optionals finalAttrs.doCheck [ gtest gbenchmark ]; + buildInputs = lib.optionals finalAttrs.doCheck [ + gbenchmark + gtest + ]; - propagatedBuildInputs = [ abseil-cpp icu ]; + propagatedBuildInputs = [ + abseil-cpp + icu + ]; cmakeFlags = [ (lib.cmakeBool "RE2_BUILD_TESTING" finalAttrs.doCheck) @@ -55,7 +68,10 @@ stdenv.mkDerivation (finalAttrs: { ''; license = licenses.bsd3; homepage = "https://github.com/google/re2"; - maintainers = with maintainers; [ azahi networkexception ]; + maintainers = with maintainers; [ + azahi + networkexception + ]; platforms = platforms.all; }; })