lol
1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, ninja
6, chromium
7, grpc
8, haskellPackages
9, mercurial
10, python3Packages
11, abseil-cpp
12}:
13
14stdenv.mkDerivation rec {
15 pname = "re2";
16 version = "2023-11-01";
17
18 src = fetchFromGitHub {
19 owner = "google";
20 repo = "re2";
21 rev = version;
22 hash = "sha256-cKXe8r5MUag/z+seem4Zg/gmqIQjaCY7DBxiKlrnXPs=";
23 };
24
25 outputs = [ "out" "dev" ];
26
27 nativeBuildInputs = [ cmake ninja ];
28
29 propagatedBuildInputs = [ abseil-cpp ];
30
31 postPatch = ''
32 substituteInPlace re2Config.cmake.in \
33 --replace "\''${PACKAGE_PREFIX_DIR}/" ""
34 '';
35
36 # Needed for case-insensitive filesystems (i.e. MacOS) because a file named
37 # BUILD already exists.
38 cmakeBuildDir = "build_dir";
39
40 cmakeFlags = lib.optional (!stdenv.hostPlatform.isStatic) "-DBUILD_SHARED_LIBS:BOOL=ON";
41
42 # This installs a pkg-config definition.
43 postInstall = ''
44 pushd "$src"
45 make common-install prefix="$dev" SED_INPLACE="sed -i"
46 popd
47 '';
48
49 doCheck = true;
50
51 passthru.tests = {
52 inherit
53 chromium
54 grpc
55 mercurial;
56 inherit (python3Packages)
57 fb-re2
58 google-re2;
59 haskell-re2 = haskellPackages.re2;
60 };
61
62 meta = with lib; {
63 description = "A regular expression library";
64 longDescription = ''
65 RE2 is a fast, safe, thread-friendly alternative to backtracking regular
66 expression engines like those used in PCRE, Perl, and Python. It is a C++
67 library.
68 '';
69 license = licenses.bsd3;
70 homepage = "https://github.com/google/re2";
71 maintainers = with maintainers; [ azahi networkexception ];
72 platforms = platforms.all;
73 };
74}