|
| 1 | +{ lib, stdenv, cmake, fetchurl, kytea, msgpack-c, mecab, pkg-config, rapidjson |
| 2 | +, testers, xxHash, zstd, postgresqlPackages, makeWrapper, suggestSupport ? false |
| 3 | +, zeromq, libevent, openssl, lz4Support ? false, lz4, zlibSupport ? true, zlib |
| 4 | +, writeShellScriptBin, callPackage }: |
| 5 | +let mecab-naist-jdic = callPackage ./ext/mecab-naist-jdic { }; |
| 6 | +in stdenv.mkDerivation (finalAttrs: { |
| 7 | + pname = "supabase-groonga"; |
| 8 | + version = "14.0.5"; |
| 9 | + src = fetchurl { |
| 10 | + url = |
| 11 | + "https://packages.groonga.org/source/groonga/groonga-${finalAttrs.version}.tar.gz"; |
| 12 | + hash = "sha256-y4UGnv8kK0z+br8wXpPf57NMXkdEJHcLCuTvYiubnIc="; |
| 13 | + }; |
| 14 | + patches = |
| 15 | + [ ./fix-cmake-install-path.patch ./do-not-use-vendored-libraries.patch ]; |
| 16 | + nativeBuildInputs = [ cmake pkg-config makeWrapper ]; |
| 17 | + buildInputs = [ rapidjson xxHash zstd mecab kytea msgpack-c ] |
| 18 | + ++ lib.optionals lz4Support [ lz4 ] ++ lib.optional zlibSupport [ zlib ] |
| 19 | + ++ lib.optionals suggestSupport [ zeromq libevent ]; |
| 20 | + cmakeFlags = [ |
| 21 | + "-DWITH_MECAB=ON" |
| 22 | + "-DMECAB_DICDIR=${mecab-naist-jdic}/lib/mecab/dic/naist-jdic" |
| 23 | + "-DMECAB_CONFIG=${mecab}/bin/mecab-config" |
| 24 | + "-DENABLE_MECAB_TOKENIZER=ON" |
| 25 | + "-DMECAB_INCLUDE_DIR=${mecab}/include" |
| 26 | + "-DMECAB_LIBRARY=${mecab}/lib/libmecab.so" |
| 27 | + "-DGROONGA_ENABLE_TOKENIZER_MECAB=YES" |
| 28 | + "-DGRN_WITH_MECAB=YES" |
| 29 | + ]; |
| 30 | + preConfigure = '' |
| 31 | + export MECAB_DICDIR=${mecab-naist-jdic}/lib/mecab/dic/naist-jdic |
| 32 | + echo "MeCab dictionary directory is: $MECAB_DICDIR" |
| 33 | + ''; |
| 34 | + buildPhase = '' |
| 35 | + cmake --build . -- VERBOSE=1 |
| 36 | + grep -i mecab CMakeCache.txt || (echo "MeCab not detected in CMake cache" && exit 1) |
| 37 | + echo "CMake cache contents related to MeCab:" |
| 38 | + grep -i mecab CMakeCache.txt |
| 39 | + ''; |
| 40 | + |
| 41 | + # installPhase = '' |
| 42 | + # mkdir -p $out/bin $out/lib/groonga/plugins |
| 43 | + # cp -r lib/groonga/plugins/* $out/lib/groonga/plugins |
| 44 | + # cp -r bin/* $out/bin |
| 45 | + # echo "Installed Groonga plugins:" |
| 46 | + # ls -l $out/lib/groonga/plugins |
| 47 | + # ''; |
| 48 | + |
| 49 | + postInstall = '' |
| 50 | + echo "Searching for MeCab-related files:" |
| 51 | + find $out -name "*mecab*" |
| 52 | +
|
| 53 | + echo "Checking Groonga plugins directory:" |
| 54 | + ls -l $out/lib/groonga/plugins |
| 55 | +
|
| 56 | + echo "Wrapping Groonga binary:" |
| 57 | + wrapProgram $out/bin/groonga \ |
| 58 | + --set GRN_PLUGINS_DIR $out/lib/groonga/plugins |
| 59 | +
|
| 60 | + ''; |
| 61 | + env.NIX_CFLAGS_COMPILE = |
| 62 | + lib.optionalString zlibSupport "-I${zlib.dev}/include"; |
| 63 | + |
| 64 | + meta = with lib; { |
| 65 | + homepage = "https://groonga.org/"; |
| 66 | + description = "Open-source fulltext search engine and column store"; |
| 67 | + license = licenses.lgpl21; |
| 68 | + maintainers = [ maintainers.samrose ]; |
| 69 | + platforms = platforms.all; |
| 70 | + longDescription = '' |
| 71 | + Groonga is an open-source fulltext search engine and column store. |
| 72 | + It lets you write high-performance applications that requires fulltext search. |
| 73 | + ''; |
| 74 | + }; |
| 75 | +}) |
0 commit comments