Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 41 additions & 38 deletions pkgs/development/libraries/re2/default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
{ lib
, stdenv
, fetchFromGitHub
, nix-update-script

# for passthru.tests
, bazel
, cmake
, ninja
, chromium
, grpc
, haskellPackages
, mercurial
, ninja
, python3
, python3Packages
}:

stdenv.mkDerivation rec {
Expand All @@ -21,48 +18,54 @@ stdenv.mkDerivation rec {
owner = "google";
repo = "re2";
rev = version;
sha256 = "sha256-UontAjOXpnPcOgoFHjf+1WSbCR7h58/U7nn4meT200Y=";
hash = "sha256-UontAjOXpnPcOgoFHjf+1WSbCR7h58/U7nn4meT200Y=";
};

preConfigure = ''
substituteInPlace Makefile --replace "/usr/local" "$out"
# we're using gnu sed, even on darwin
substituteInPlace Makefile --replace "SED_INPLACE=sed -i '''" "SED_INPLACE=sed -i"
'';
outputs = [ "out" "dev" ];

buildFlags = lib.optionals stdenv.hostPlatform.isStatic [ "static" ];
nativeBuildInputs = [ cmake ninja ];

enableParallelBuilding = true;
postPatch = ''
substituteInPlace re2Config.cmake.in \
--replace "\''${PACKAGE_PREFIX_DIR}/" ""
'';

preCheck = "patchShebangs runtests";
doCheck = true;
checkTarget = if stdenv.hostPlatform.isStatic then "static-test" else "test";
# 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";

installTargets = lib.optionals stdenv.hostPlatform.isStatic [ "static-install" ];
# This installs a pkg-config definition.
postInstall = ''
pushd "$src"
make common-install prefix="$dev" SED_INPLACE="sed -i"
popd
'';

doInstallCheck = true;
installCheckTarget = if stdenv.hostPlatform.isStatic then "static-testinstall" else "testinstall";
doCheck = true;

passthru = {
updateScript = nix-update-script {
attrPath = pname;
};
tests = {
inherit
chromium
grpc
mercurial;
inherit (python3.pkgs)
fb-re2
google-re2;
haskellPackages-re2 = haskellPackages.re2;
};
passthru.tests = {
inherit
chromium
grpc
mercurial;
inherit (python3Packages)
fb-re2
google-re2;
haskell-re2 = haskellPackages.re2;
};

meta = {
meta = with lib; {
description = "A regular expression library";
longDescription = ''
RE2 is a fast, safe, thread-friendly alternative to backtracking regular
expression engines like those used in PCRE, Perl, and Python. It is a C++
library.
'';
license = licenses.bsd3;
homepage = "https://github.com/google/re2";
description = "An efficient, principled regular expression library";
license = lib.licenses.bsd3;
platforms = with lib.platforms; all;
maintainers = with maintainers; [ azahi ];
platforms = platforms.all;
};
}