2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake, ragel, python3
|
2021-12-06 16:07:01 +00:00
|
|
|
, coreutils, gnused, util-linux, fetchpatch
|
2020-04-24 23:36:52 +00:00
|
|
|
, boost
|
|
|
|
, withStatic ? false # build only shared libs by default, build static+shared if true
|
|
|
|
}:
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
# NOTICE: pkg-config, pcap and pcre intentionally omitted from build inputs
|
|
|
|
# pcap used only in examples, pkg-config used only to check for pcre
|
2020-04-24 23:36:52 +00:00
|
|
|
# which is fixed 8.41 version requirement (nixpkgs have 8.42+, and
|
|
|
|
# I not see any reason (for now) to backport 8.41.
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "hyperscan";
|
2021-05-03 20:48:10 +00:00
|
|
|
version = "5.4.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "intel";
|
|
|
|
repo = pname;
|
2021-05-03 20:48:10 +00:00
|
|
|
sha256 = "sha256-AJAjaXVnGqIlMk+gb6lpTLUdZr8nxn2XSW4fj6j/cmk=";
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = "v${version}";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
buildInputs = [ boost ];
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake ragel python3
|
|
|
|
# Consider simply using busybox for these
|
|
|
|
# Need at least: rev, sed, cut, nm
|
2020-11-24 20:58:05 +00:00
|
|
|
coreutils gnused util-linux
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DFAT_RUNTIME=ON"
|
|
|
|
"-DBUILD_AVX512=ON"
|
|
|
|
]
|
2021-02-05 17:12:51 +00:00
|
|
|
++ lib.optional (withStatic) "-DBUILD_STATIC_AND_SHARED=ON"
|
|
|
|
++ lib.optional (!withStatic) "-DBUILD_SHARED_LIBS=ON";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
# part of https://github.com/intel/hyperscan/pull/336
|
|
|
|
url = "https://github.com/intel/hyperscan/commit/e2c4010b1fc1272cab816ba543940b3586e68a0c.patch";
|
|
|
|
sha256 = "sha256-doVNwROL6MTcgOW8jBwGTnxe0zvxjawiob/g6AvXLak=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postPatch = ''
|
|
|
|
sed -i '/examples/d' CMakeLists.txt
|
|
|
|
substituteInPlace libhs.pc.in \
|
|
|
|
--replace "libdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@" "libdir=@CMAKE_INSTALL_LIBDIR@" \
|
|
|
|
--replace "includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@" "includedir=@CMAKE_INSTALL_INCLUDEDIR@"
|
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "High-performance multiple regex matching library";
|
|
|
|
longDescription = ''
|
|
|
|
Hyperscan is a high-performance multiple regex matching library.
|
|
|
|
It follows the regular expression syntax of the commonly-used
|
|
|
|
libpcre library, but is a standalone library with its own C API.
|
|
|
|
|
|
|
|
Hyperscan uses hybrid automata techniques to allow simultaneous
|
|
|
|
matching of large numbers (up to tens of thousands) of regular
|
2021-02-05 17:12:51 +00:00
|
|
|
expressions and for the matching of regular expressions across
|
2020-04-24 23:36:52 +00:00
|
|
|
streams of data.
|
|
|
|
|
|
|
|
Hyperscan is typically used in a DPI library stack.
|
|
|
|
'';
|
|
|
|
|
|
|
|
homepage = "https://www.hyperscan.io/";
|
|
|
|
maintainers = with maintainers; [ avnik ];
|
|
|
|
platforms = [ "x86_64-linux" ]; # can't find nm on darwin ; might build on aarch64 but untested
|
|
|
|
license = licenses.bsd3;
|
|
|
|
};
|
|
|
|
}
|