|
1 |
| -# { lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, callPackage |
2 |
| -# , makeWrapper, mecab }: |
3 |
| - |
4 |
| -# let |
5 |
| -# supabase-groonga = callPackage ../supabase-groonga.nix { }; |
6 |
| -# mecab-naist-jdic = callPackage ./mecab-naist-jdic { }; |
7 |
| -# in stdenv.mkDerivation rec { |
8 |
| -# pname = "pgroonga"; |
9 |
| -# version = "3.0.7"; |
10 |
| -# src = fetchurl { |
11 |
| -# url = |
12 |
| -# "https://packages.groonga.org/source/${pname}/${pname}-${version}.tar.gz"; |
13 |
| -# sha256 = "sha256-iF/zh4zDDpAw5fxW1WG8i2bfPt4VYsnYArwOoE/lwgM="; |
14 |
| -# }; |
15 |
| -# nativeBuildInputs = [ pkg-config makeWrapper ]; |
16 |
| -# buildInputs = [ postgresql msgpack-c supabase-groonga mecab mecab-naist-jdic ]; |
17 |
| - |
18 |
| -# makeFlags = [ |
19 |
| -# "USE_PGXS=1" |
20 |
| -# "HAVE_MSGPACK=1" |
21 |
| -# "MSGPACK_PACKAGE_NAME=msgpack-c" |
22 |
| -# "HAVE_MECAB=1" |
23 |
| -# "POSTGRES_INCLUDEDIR=${postgresql}/include" |
24 |
| -# "POSTGRES_LIBDIR=${postgresql.lib}/lib" |
25 |
| -# "PG_CONFIG=${postgresql}/bin/pg_config" |
26 |
| -# "MECAB_CONFIG=${mecab}/bin/mecab-config" |
27 |
| -# "MECAB_LIBRARIES=-L${mecab}/lib -lmecab" |
28 |
| -# "GROONGA_INCLUDES=-I${supabase-groonga}/include" |
29 |
| -# "GROONGA_LIBS=-L${supabase-groonga}/lib -lgroonga" |
30 |
| -# "GROONGA_PLUGIN_LIBS=-L${supabase-groonga}/lib/groonga/plugins" |
31 |
| -# ]; |
32 |
| - |
33 |
| -# configureFlags = [ |
34 |
| -# "--with-mecab=${mecab}" |
35 |
| -# "--enable-mecab" |
36 |
| -# "--with-mecab-config=${mecab}/bin/mecab-config" |
37 |
| -# "--with-mecab-dict=${mecab-naist-jdic}/lib/mecab/dic/naist-jdic" |
38 |
| -# "--with-groonga=${supabase-groonga}" |
39 |
| -# "--with-groonga-plugin-dir=${supabase-groonga}/lib/groonga/plugins" |
40 |
| -# ]; |
41 |
| - |
42 |
| -# preConfigure = '' |
43 |
| -# export MECAB_DICDIR=${mecab-naist-jdic}/lib/mecab/dic/naist-jdic |
44 |
| -# export GROONGA_INCLUDE_PATH=${supabase-groonga}/include |
45 |
| -# export GROONGA_LIB_PATH=${supabase-groonga}/lib |
46 |
| -# export MECAB_INCLUDE_PATH=${mecab}/include |
47 |
| -# export MECAB_LIB_PATH=${mecab}/lib |
48 |
| -# export PKG_CONFIG_PATH="${supabase-groonga}/lib/pkgconfig:$PKG_CONFIG_PATH" |
49 |
| -# export GRN_PLUGINS_PATH=${supabase-groonga}/lib/groonga/plugins |
50 |
| - |
51 |
| -# # Ensure MeCab is enabled |
52 |
| -# sed -i 's|#define HAVE_MECAB 0|#define HAVE_MECAB 1|' src/pgroonga.h |
53 |
| -# ''; |
54 |
| - |
55 |
| -# installPhase = '' |
56 |
| -# runHook preInstall |
57 |
| -# make $makeFlags install DESTDIR=$out |
58 |
| -# install -D pgroonga${postgresql.dlSuffix} -t $out/lib/ |
59 |
| -# install -D pgroonga.control -t $out/share/postgresql/extension |
60 |
| -# install -D data/pgroonga-*.sql -t $out/share/postgresql/extension |
61 |
| -# install -D pgroonga_database${postgresql.dlSuffix} -t $out/lib/ |
62 |
| -# install -D pgroonga_database.control -t $out/share/postgresql/extension |
63 |
| -# install -D data/pgroonga_database-*.sql -t $out/share/postgresql/extension |
64 |
| - |
65 |
| -# for component in pgroonga_check pgroonga_wal_applier pgroonga_crash_safer pgroonga_standby_maintainer; do |
66 |
| -# if [ -f "$component${postgresql.dlSuffix}" ]; then |
67 |
| -# install -D "$component${postgresql.dlSuffix}" -t $out/lib/ |
68 |
| -# fi |
69 |
| -# done |
70 |
| - |
71 |
| -# # Ensure Groonga plugins are accessible |
72 |
| -# mkdir -p $out/lib/groonga/plugins |
73 |
| -# cp -r ${supabase-groonga}/lib/groonga/plugins/* $out/lib/groonga/plugins/ |
74 |
| - |
75 |
| -# # Create a wrapper script for pgroonga |
76 |
| -# mkdir -p $out/bin |
77 |
| -# makeWrapper ${postgresql}/bin/postgres $out/bin/pgroonga-postgres \ |
78 |
| -# --set GRN_PLUGINS_PATH ${supabase-groonga}/lib/groonga/plugins \ |
79 |
| -# --set LD_LIBRARY_PATH ${lib.makeLibraryPath buildInputs}:${supabase-groonga}/lib:$out/lib:$out/lib/groonga/plugins |
80 |
| - |
81 |
| -# # Create SQL scripts to apply the necessary settings |
82 |
| -# cat << EOF > $out/share/postgresql/extension/pgroonga_set_paths.sql |
83 |
| -# DO \$\$ |
84 |
| -# BEGIN |
85 |
| -# SET pgroonga.log_path TO current_setting('data_directory') || '/groonga.log'; |
86 |
| -# SET pgroonga.libgroonga_path TO '${supabase-groonga}/lib/libgroonga${stdenv.hostPlatform.extensions.sharedLibrary}'; |
87 |
| -# SET pgroonga.groonga_plugin_path TO '${supabase-groonga}/lib/groonga/plugins'; |
88 |
| -# END \$\$; |
89 |
| -# EOF |
90 |
| -# chmod +x $out/share/postgresql/extension/pgroonga_set_paths.sql |
91 |
| - |
92 |
| -# runHook postInstall |
93 |
| -# ''; |
94 |
| - |
95 |
| -# postFixup = '' |
96 |
| -# for f in $out/lib/*.so; do |
97 |
| -# patchelf --set-rpath "${lib.makeLibraryPath buildInputs}:${supabase-groonga}/lib:$out/lib:$out/lib/groonga/plugins" $f |
98 |
| -# done |
99 |
| -# ''; |
100 |
| - |
101 |
| -# meta = with lib; { |
102 |
| -# description = "A PostgreSQL extension to use Groonga as the index"; |
103 |
| -# longDescription = '' |
104 |
| -# PGroonga is a PostgreSQL extension to use Groonga as the index. |
105 |
| -# PostgreSQL supports full text search against languages that use only alphabet and digit. |
106 |
| -# It means that PostgreSQL doesn't support full text search against Japanese, Chinese and so on. |
107 |
| -# You can use super fast full text search feature against all languages by installing PGroonga into your PostgreSQL. |
108 |
| -# ''; |
109 |
| -# homepage = "https://pgroonga.github.io/"; |
110 |
| -# changelog = "https://github.com/pgroonga/pgroonga/releases/tag/${version}"; |
111 |
| -# license = licenses.postgresql; |
112 |
| -# platforms = postgresql.meta.platforms; |
113 |
| -# maintainers = with maintainers; [ samrose ]; |
114 |
| -# }; |
115 |
| -# } |
116 |
| - |
117 | 1 | { lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, callPackage, mecab, makeWrapper }:
|
118 | 2 | let
|
119 | 3 | supabase-groonga = callPackage ../supabase-groonga.nix { };
|
@@ -156,11 +40,15 @@ stdenv.mkDerivation rec {
|
156 | 40 | install -D pgroonga_database.control -t $out/share/postgresql/extension
|
157 | 41 | install -D data/pgroonga_database-*.sql -t $out/share/postgresql/extension
|
158 | 42 |
|
| 43 | + # Modify the main PGroonga SQL file to include MeCab plugin registration |
| 44 | + for sql_file in $out/share/postgresql/extension/pgroonga-*.sql; do |
| 45 | + echo "SELECT pgroonga_command('plugin_register ${supabase-groonga}/lib/groonga/plugins/tokenizers/mecab.so');" >> $sql_file |
| 46 | + done |
| 47 | +
|
159 | 48 | cat << EOF > $out/share/postgresql/extension/pgroonga_set_paths.sql
|
160 | 49 | DO \$\$
|
161 | 50 | BEGIN
|
162 | 51 | SET pgroonga.log_path TO current_setting('data_directory') || '/groonga.log';
|
163 |
| - PERFORM pgroonga_command('plugin_register ${supabase-groonga}/lib/groonga/plugins/tokenizers/mecab.so'); |
164 | 52 | END \$\$;
|
165 | 53 | EOF
|
166 | 54 | chmod +x $out/share/postgresql/extension/pgroonga_set_paths.sql
|
|
0 commit comments