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; }; -} +})