Merge pull request #329823 from ExpidusOS/fix/pkgsllvm/elfutils
[NixPkgs.git] / pkgs / by-name / ma / manticoresearch / package.nix
blobb6022a04303d9cf17bdbcd5ebbad57f9aa38ab0a
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , bison
5 , cmake
6 , flex
7 , pkg-config
8 , boost
9 , icu
10 , libstemmer
11 , mariadb-connector-c
12 , re2
13 , nlohmann_json
14 , testers
15 , manticoresearch
18 let
19   columnar = stdenv.mkDerivation (finalAttrs: {
20     pname = "columnar";
21     version = "c21-s10"; # see NEED_COLUMNAR_API/NEED_SECONDARY_API in Manticore's cmake/GetColumnar.cmake
22     src = fetchFromGitHub {
23       owner = "manticoresoftware";
24       repo = "columnar";
25       rev = finalAttrs.version;
26       hash = "sha256-TGFGFfoyHnPSr2U/9dpqFLUN3Dt2jDQrTF/xxDY4pdE=";
27     };
28     nativeBuildInputs = [ cmake ];
29     cmakeFlags = [ "-DAPI_ONLY=ON" ];
30     meta = {
31       description = "Column-oriented storage and secondary indexing library";
32       homepage = "https://github.com/manticoresoftware/columnar/";
33       license = lib.licenses.asl20;
34       platforms = lib.platforms.all;
35     };
36   });
37   uni-algo = stdenv.mkDerivation (finalAttrs: {
38     pname = "uni-algo";
39     version = "0.7.2";
40     src = fetchFromGitHub {
41       owner = "manticoresoftware";
42       repo = "uni-algo";
43       rev = "v${finalAttrs.version}";
44       hash = "sha256-+V9w4UJ+3KsyZUYht6OEzms60mBHd8FewVc7f21Z9ww=";
45     };
46     nativeBuildInputs = [ cmake ];
47     meta = {
48       description = "Unicode Algorithms Implementation for C/C++";
49       homepage = "https://github.com/manticoresoftware/uni-algo";
50       license = lib.licenses.mit;
51       platforms = lib.platforms.all;
52     };
53   });
55 stdenv.mkDerivation (finalAttrs: {
56   pname = "manticoresearch";
57   version = "6.2.12";
59   src = fetchFromGitHub {
60     owner = "manticoresoftware";
61     repo = "manticoresearch";
62     rev = "refs/tags/${finalAttrs.version}";
63     hash = "sha256-UD/r7rlJ5mR3wg4doKT/nTwTWzlulngUjOPNEjmykB8=";
64   };
66   nativeBuildInputs = [
67     bison
68     cmake
69     flex
70     pkg-config
71   ];
73   buildInputs = [
74     boost
75     columnar
76     icu.dev
77     libstemmer
78     mariadb-connector-c
79     nlohmann_json
80     uni-algo
81     re2
82   ];
84   postPatch = ''
85     sed -i 's/set ( Boost_USE_STATIC_LIBS ON )/set ( Boost_USE_STATIC_LIBS OFF )/' src/CMakeLists.txt
87     # supply our own packages rather than letting manticore download dependencies during build
88     sed -i 's/^with_get/with_menu/' CMakeLists.txt
89     sed -i 's/get_dep \( nlohmann_json .* \)/find_package(nlohmann_json)/' CMakeLists.txt
90     sed -i 's/get_dep \( uni-algo .* \)/find_package(uni-algo)/' CMakeLists.txt
91   '';
93   cmakeFlags = [
94     "-DWITH_GALERA=0"
95     "-DWITH_MYSQL=1"
96     "-DMYSQL_INCLUDE_DIR=${mariadb-connector-c.dev}/include/mariadb"
97     "-DMYSQL_LIB=${mariadb-connector-c.out}/lib/mariadb/libmysqlclient.a"
98     "-DCONFDIR=${placeholder "out"}/etc"
99     "-DLOGDIR=/var/lib/manticoresearch/log"
100     "-DRUNDIR=/var/run/manticoresearch"
101   ];
103   postFixup = ''
104     mkdir -p $out/lib/systemd/system
105     cp ${finalAttrs.src}/dist/deb/manticore.service.in $out/lib/systemd/system/manticore.service
106     substituteInPlace $out/lib/systemd/system/manticore.service \
107       --replace "@CMAKE_INSTALL_FULL_RUNSTATEDIR@" "/var/lib/manticore" \
108       --replace "@CMAKE_INSTALL_FULL_BINDIR@" "$out/bin" \
109       --replace "@CMAKE_INSTALL_FULL_SYSCONFDIR@" "$out/etc"
110   '';
112   passthru.tests.version = testers.testVersion {
113     inherit (finalAttrs) version;
114     package = manticoresearch;
115     command = "searchd --version";
116   };
118   meta = with lib; {
119     description = "Easy to use open source fast database for search";
120     homepage = "https://manticoresearch.com";
121     changelog = "https://github.com/manticoresoftware/manticoresearch/releases/tag/${finalAttrs.version}";
122     license = licenses.gpl2;
123     mainProgram = "searchd";
124     maintainers = [ maintainers.jdelStrother ];
125     platforms = platforms.all;
126   };