|
| 1 | +{ |
| 2 | + lib, |
| 3 | + stdenv, |
| 4 | + fetchurl, |
| 5 | + pkg-config, |
| 6 | + postgresql, |
| 7 | + msgpack-c, |
| 8 | + mecab, |
| 9 | + makeWrapper, |
| 10 | + xxHash, |
| 11 | + supabase-groonga, |
| 12 | +}: |
| 13 | +stdenv.mkDerivation rec { |
| 14 | + pname = "pgroonga"; |
| 15 | + version = "3.2.5"; |
| 16 | + src = fetchurl { |
| 17 | + url = "https://packages.groonga.org/source/${pname}/${pname}-${version}.tar.gz"; |
| 18 | + sha256 = "sha256-GM9EOQty72hdE4Ecq8jpDudhZLiH3pP9ODLxs8DXcSY="; |
| 19 | + }; |
| 20 | + |
| 21 | + nativeBuildInputs = [ |
| 22 | + pkg-config |
| 23 | + makeWrapper |
| 24 | + ]; |
| 25 | + |
| 26 | + buildInputs = [ |
| 27 | + postgresql |
| 28 | + msgpack-c |
| 29 | + supabase-groonga |
| 30 | + mecab |
| 31 | + ] |
| 32 | + ++ lib.optionals stdenv.isDarwin [ xxHash ]; |
| 33 | + |
| 34 | + propagatedBuildInputs = [ supabase-groonga ]; |
| 35 | + configureFlags = [ |
| 36 | + "--with-mecab=${mecab}" |
| 37 | + "--enable-mecab" |
| 38 | + "--with-groonga=${supabase-groonga}" |
| 39 | + "--with-groonga-plugin-dir=${supabase-groonga}/lib/groonga/plugins" |
| 40 | + ]; |
| 41 | + |
| 42 | + makeFlags = [ |
| 43 | + "HAVE_MSGPACK=1" |
| 44 | + "MSGPACK_PACKAGE_NAME=msgpack-c" |
| 45 | + "HAVE_MECAB=1" |
| 46 | + ]; |
| 47 | + |
| 48 | + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin ( |
| 49 | + builtins.concatStringsSep " " [ |
| 50 | + "-Wno-error=incompatible-function-pointer-types" |
| 51 | + "-Wno-error=format" |
| 52 | + "-Wno-format" |
| 53 | + "-I${supabase-groonga}/include/groonga" |
| 54 | + "-I${xxHash}/include" |
| 55 | + "-DPGRN_VERSION=\"${version}\"" |
| 56 | + ] |
| 57 | + ); |
| 58 | + |
| 59 | + preConfigure = '' |
| 60 | + export GROONGA_LIBS="-L${supabase-groonga}/lib -lgroonga" |
| 61 | + export GROONGA_CFLAGS="-I${supabase-groonga}/include" |
| 62 | + export MECAB_CONFIG="${mecab}/bin/mecab-config" |
| 63 | + ${lib.optionalString stdenv.isDarwin '' |
| 64 | + export CPPFLAGS="-I${supabase-groonga}/include/groonga -I${xxHash}/include -DPGRN_VERSION=\"${version}\"" |
| 65 | + export CFLAGS="-I${supabase-groonga}/include/groonga -I${xxHash}/include -DPGRN_VERSION=\"${version}\"" |
| 66 | + export PG_CPPFLAGS="-Wno-error=incompatible-function-pointer-types -Wno-error=format" |
| 67 | + ''} |
| 68 | + ''; |
| 69 | + |
| 70 | + installPhase = '' |
| 71 | + mkdir -p $out/lib $out/share/postgresql/extension $out/bin |
| 72 | + install -D pgroonga${postgresql.dlSuffix} -t $out/lib/ |
| 73 | + install -D pgroonga.control -t $out/share/postgresql/extension |
| 74 | + install -D data/pgroonga-*.sql -t $out/share/postgresql/extension |
| 75 | + install -D pgroonga_database${postgresql.dlSuffix} -t $out/lib/ |
| 76 | + install -D pgroonga_database.control -t $out/share/postgresql/extension |
| 77 | + install -D data/pgroonga_database-*.sql -t $out/share/postgresql/extension |
| 78 | +
|
| 79 | + echo "Debug: Groonga plugins directory contents:" |
| 80 | + ls -l ${supabase-groonga}/lib/groonga/plugins/tokenizers/ |
| 81 | + ''; |
| 82 | + |
| 83 | + meta = with lib; { |
| 84 | + description = "A PostgreSQL extension to use Groonga as the index"; |
| 85 | + longDescription = '' |
| 86 | + PGroonga is a PostgreSQL extension to use Groonga as the index. |
| 87 | + PostgreSQL supports full text search against languages that use only alphabet and digit. |
| 88 | + It means that PostgreSQL doesn't support full text search against Japanese, Chinese and so on. |
| 89 | + You can use super fast full text search feature against all languages by installing PGroonga into your PostgreSQL. |
| 90 | + ''; |
| 91 | + homepage = "https://pgroonga.github.io/"; |
| 92 | + changelog = "https://github.com/pgroonga/pgroonga/releases/tag/${version}"; |
| 93 | + license = licenses.postgresql; |
| 94 | + platforms = postgresql.meta.platforms; |
| 95 | + }; |
| 96 | +} |
0 commit comments