1{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, boost, gtest, zlib }:
2
3stdenv.mkDerivation rec {
4 pname = "lucene++";
5 version = "3.0.8";
6
7 src = fetchFromGitHub {
8 owner = "luceneplusplus";
9 repo = "LucenePlusPlus";
10 rev = "rel_${version}";
11 sha256 = "12v7r62f7pqh5h210pb74sfx6h70lj4pgfpva8ya2d55fn0qxrr2";
12 };
13
14 nativeBuildInputs = [ cmake ];
15 buildInputs = [ boost gtest zlib ];
16
17 cmakeFlags = [ "-DCMAKE_INSTALL_LIBDIR=lib" ];
18
19 patches = [
20 (fetchpatch {
21 name = "pkgconfig_use_correct_LIBDIR_for_destination_library";
22 url = "https://github.com/luceneplusplus/LucenePlusPlus/commit/39cd44bd54e918d25ee464477992ad0dc234dcba.patch";
23 sha256 = "sha256-PP6ENNhPJMWrYDlTnr156XV8d5aX/VNX8v4vvi9ZiWo";
24 })
25 (fetchpatch {
26 name = "fix-visibility-on-mac.patch";
27 url = "https://github.com/luceneplusplus/LucenePlusPlus/commit/bc436842227aea561b68c6ae89fbd1fdefcac7b3.patch";
28 sha256 = "sha256-/S7tFZ4ht5p0cv036xF2NKZQwExbPaGINyWZiUg/lS4=";
29 })
30 ];
31
32 # Don't use the built in gtest - but the nixpkgs one requires C++14.
33 postPatch = ''
34 substituteInPlace src/test/CMakeLists.txt \
35 --replace "add_subdirectory(gtest)" ""
36 substituteInPlace CMakeLists.txt \
37 --replace "set(CMAKE_CXX_STANDARD 11)" "set(CMAKE_CXX_STANDARD 14)"
38 '';
39
40 doCheck = true;
41
42 checkPhase = ''
43 runHook preCheck
44 LD_LIBRARY_PATH=$PWD/src/contrib:$PWD/src/core \
45 src/test/lucene++-tester
46 runHook postCheck
47 '';
48
49 postInstall = ''
50 mv $out/include/pkgconfig $out/lib/
51 cp $src/src/contrib/include/*h $out/include/lucene++/
52 '';
53
54 meta = {
55 description = "C++ port of the popular Java Lucene search engine";
56 homepage = "https://github.com/luceneplusplus/LucenePlusPlus";
57 license = with lib.licenses; [ asl20 lgpl3Plus ];
58 platforms = lib.platforms.unix;
59 };
60}