|
1 |
| -# { lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, mecab, callPackage |
2 |
| -# , patchelf }: |
| 1 | +# { lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, callPackage |
| 2 | +# , makeWrapper, mecab }: |
| 3 | + |
3 | 4 | # let
|
4 | 5 | # supabase-groonga = callPackage ../supabase-groonga.nix { };
|
5 | 6 | # mecab-naist-jdic = callPackage ./mecab-naist-jdic { };
|
|
11 | 12 | # "https://packages.groonga.org/source/${pname}/${pname}-${version}.tar.gz";
|
12 | 13 | # sha256 = "sha256-iF/zh4zDDpAw5fxW1WG8i2bfPt4VYsnYArwOoE/lwgM=";
|
13 | 14 | # };
|
14 |
| -# nativeBuildInputs = [ pkg-config patchelf ]; |
15 |
| -# buildInputs = |
16 |
| -# [ postgresql msgpack-c supabase-groonga mecab mecab-naist-jdic ]; |
17 |
| - |
| 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 | + |
18 | 33 | # configureFlags = [
|
19 | 34 | # "--with-mecab=${mecab}"
|
20 | 35 | # "--enable-mecab"
|
21 |
| -# "--enable-groonga-tokenizer-mecab" |
| 36 | +# "--with-mecab-config=${mecab}/bin/mecab-config" |
22 | 37 | # "--with-mecab-dict=${mecab-naist-jdic}/lib/mecab/dic/naist-jdic"
|
23 | 38 | # "--with-groonga=${supabase-groonga}"
|
24 |
| -# "--with-groonga-token-mecab-dir=${supabase-groonga}/lib/groonga/plugins/tokenizers" |
25 |
| -# "--with-groonga-tokenizer-mecab=${supabase-groonga}/lib/groonga/plugins/tokenizers/mecab.so" |
26 | 39 | # "--with-groonga-plugin-dir=${supabase-groonga}/lib/groonga/plugins"
|
27 |
| -# "--with-pgconfigdir=${postgresql}/bin" |
28 |
| -# "--with-mecab-config=${mecab}/bin/mecab-config" |
29 | 40 | # ];
|
30 | 41 |
|
31 |
| -# makeFlags = |
32 |
| -# [ "HAVE_MSGPACK=1" "MSGPACK_PACKAGE_NAME=msgpack-c" "HAVE_MECAB=1" ]; |
33 |
| - |
34 |
| -# buildPhase = '' |
35 |
| -# runHook preBuild |
36 |
| -# make |
37 |
| -# echo "Checking for MeCab-related files:" |
38 |
| -# find . -name "*mecab*" |
39 |
| -# runHook postBuild |
| 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 |
40 | 53 | # '';
|
41 | 54 |
|
42 | 55 | # installPhase = ''
|
43 | 56 | # runHook preInstall
|
44 |
| - |
45 |
| -# install -D pgroonga${postgresql.dlSuffix} -t $out/lib/ |
46 |
| -# install -D pgroonga.control -t $out/share/postgresql/extension/ |
47 |
| -# install -D data/pgroonga-*.sql -t $out/share/postgresql/extension/ |
48 |
| -# install -D pgroonga_database${postgresql.dlSuffix} -t $out/lib/ |
49 |
| -# install -D pgroonga_database.control -t $out/share/postgresql/extension/ |
50 |
| -# install -D data/pgroonga_database-*.sql -t $out/share/postgresql/extension/ |
51 |
| - |
52 |
| -# # Ensure MeCab tokenizer is available |
53 |
| -# if [ -f ${supabase-groonga}/lib/groonga/plugins/tokenizers/mecab.so ]; then |
54 |
| -# mkdir -p $out/lib/postgresql/plugins/ |
55 |
| -# cp ${supabase-groonga}/lib/groonga/plugins/tokenizers/mecab.so $out/lib/postgresql/plugins/ |
56 |
| -# else |
57 |
| -# echo "MeCab tokenizer plugin not found in Groonga installation" |
58 |
| -# exit 1 |
59 |
| -# fi |
60 |
| - |
61 |
| -# runHook postInstall |
62 |
| -# ''; |
63 |
| - |
64 |
| -# postInstall = '' |
65 |
| -# echo "Checking installed files:" |
66 |
| -# find $out -type f |
67 |
| - |
68 |
| -# echo "Checking for MeCab-related files in the output:" |
69 |
| -# find $out -name "*mecab*" |
70 |
| -# ''; |
71 |
| - |
72 |
| -# postFixup = '' |
73 |
| -# patchelf --set-rpath "${ |
74 |
| -# lib.makeLibraryPath [ |
75 |
| -# mecab |
76 |
| -# mecab-naist-jdic |
77 |
| -# supabase-groonga |
78 |
| -# postgresql |
79 |
| -# stdenv.cc.cc.lib |
80 |
| -# msgpack-c |
81 |
| -# ] |
82 |
| -# }" $out/lib/pgroonga${postgresql.dlSuffix} |
83 |
| -# patchelf --set-rpath "${ |
84 |
| -# lib.makeLibraryPath [ |
85 |
| -# mecab |
86 |
| -# mecab-naist-jdic |
87 |
| -# supabase-groonga |
88 |
| -# postgresql |
89 |
| -# stdenv.cc.cc.lib |
90 |
| -# msgpack-c |
91 |
| -# ] |
92 |
| -# }" $out/lib/pgroonga_database${postgresql.dlSuffix} |
93 |
| -# ''; |
94 |
| - |
95 |
| -# meta = with lib; { |
96 |
| -# description = "A PostgreSQL extension to use Groonga as the index"; |
97 |
| -# longDescription = '' |
98 |
| -# PGroonga is a PostgreSQL extension to use Groonga as the index. |
99 |
| -# PostgreSQL supports full text search against languages that use only alphabet and digit. |
100 |
| -# It means that PostgreSQL doesn't support full text search against Japanese, Chinese and so on. |
101 |
| -# You can use super fast full text search feature against all languages by installing PGroonga into your PostgreSQL. |
102 |
| -# ''; |
103 |
| -# homepage = "https://pgroonga.github.io/"; |
104 |
| -# changelog = "https://github.com/pgroonga/pgroonga/releases/tag/${version}"; |
105 |
| -# license = licenses.postgresql; |
106 |
| -# platforms = postgresql.meta.platforms; |
107 |
| -# maintainers = with maintainers; [ samrose ]; |
108 |
| -# }; |
109 |
| -# } |
110 |
| - |
111 |
| -# { lib, stdenv, fetchurl, pkg-config, postgresql, cmake, msgpack-c, mecab, callPackage }: |
112 |
| -# let |
113 |
| -# supabase-groonga = callPackage ../supabase-groonga.nix { }; |
114 |
| -# mecab-naist-jdic = callPackage ./mecab-naist-jdic { }; |
115 |
| -# in |
116 |
| -# stdenv.mkDerivation rec { |
117 |
| -# pname = "pgroonga"; |
118 |
| -# version = "3.0.7"; |
119 |
| - |
120 |
| -# src = fetchurl { |
121 |
| -# url = "https://packages.groonga.org/source/${pname}/${pname}-${version}.tar.gz"; |
122 |
| -# sha256 = "sha256-iF/zh4zDDpAw5fxW1WG8i2bfPt4VYsnYArwOoE/lwgM="; |
123 |
| -# }; |
124 |
| - |
125 |
| -# nativeBuildInputs = [ cmake pkg-config ]; |
126 |
| -# buildInputs = [ postgresql msgpack-c supabase-groonga mecab mecab-naist-jdic ]; |
127 |
| - |
128 |
| -# makeFlags = [ |
129 |
| -# "HAVE_MSGPACK=1" |
130 |
| -# "MSGPACK_PACKAGE_NAME=msgpack-c" |
131 |
| -# ]; |
132 |
| - |
133 |
| -# installPhase = '' |
| 57 | +# make $makeFlags install DESTDIR=$out |
134 | 58 | # install -D pgroonga${postgresql.dlSuffix} -t $out/lib/
|
135 | 59 | # install -D pgroonga.control -t $out/share/postgresql/extension
|
136 | 60 | # install -D data/pgroonga-*.sql -t $out/share/postgresql/extension
|
137 |
| - |
138 | 61 | # install -D pgroonga_database${postgresql.dlSuffix} -t $out/lib/
|
139 | 62 | # install -D pgroonga_database.control -t $out/share/postgresql/extension
|
140 | 63 | # install -D data/pgroonga_database-*.sql -t $out/share/postgresql/extension
|
141 |
| -# ''; |
142 | 64 |
|
143 |
| -# meta = with lib; { |
144 |
| -# description = "A PostgreSQL extension to use Groonga as the index"; |
145 |
| -# longDescription = '' |
146 |
| -# PGroonga is a PostgreSQL extension to use Groonga as the index. |
147 |
| -# PostgreSQL supports full text search against languages that use only alphabet and digit. |
148 |
| -# It means that PostgreSQL doesn't support full text search against Japanese, Chinese and so on. |
149 |
| -# You can use super fast full text search feature against all languages by installing PGroonga into your PostgreSQL. |
150 |
| -# ''; |
151 |
| -# homepage = "https://pgroonga.github.io/"; |
152 |
| -# changelog = "https://github.com/pgroonga/pgroonga/releases/tag/${version}"; |
153 |
| -# license = licenses.postgresql; |
154 |
| -# platforms = postgresql.meta.platforms; |
155 |
| -# maintainers = with maintainers; [ samrose ]; |
156 |
| -# }; |
157 |
| -# } |
| 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 |
158 | 91 |
|
159 |
| -# { lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, callPackage, cmake, mecab }: |
160 |
| -# let |
161 |
| -# supabase-groonga = callPackage ../supabase-groonga.nix { }; |
162 |
| -# mecab-naist-jdic = callPackage ./mecab-naist-jdic { }; |
163 |
| -# in |
164 |
| -# stdenv.mkDerivation rec { |
165 |
| -# pname = "pgroonga"; |
166 |
| -# version = "3.0.7"; |
167 |
| -# src = fetchurl { |
168 |
| -# url = "https://packages.groonga.org/source/${pname}/${pname}-${version}.tar.gz"; |
169 |
| -# sha256 = "sha256-iF/zh4zDDpAw5fxW1WG8i2bfPt4VYsnYArwOoE/lwgM="; |
170 |
| -# }; |
171 |
| -# patches = [ ./use-system-groonga.patch ]; |
172 |
| -# nativeBuildInputs = [ pkg-config cmake ]; |
173 |
| -# buildInputs = [ postgresql msgpack-c supabase-groonga mecab mecab-naist-jdic ]; |
174 |
| -# cmakeFlags = [ |
175 |
| -# "-DCMAKE_PREFIX_PATH=${supabase-groonga}" |
176 |
| -# "-DMECAB_CONFIG=${mecab}/bin/mecab-config" |
177 |
| -# "-DMECAB_DICT_INDEX=${mecab}/libexec/mecab/mecab-dict-index" |
178 |
| -# "-DMECAB_DIC_DIR=${mecab-naist-jdic}/lib/mecab/dic/naist-jdic" |
179 |
| -# "-DCMAKE_BUILD_TYPE=Release" |
180 |
| -# "-DBUILD_TESTING=OFF" |
181 |
| -# ]; |
182 |
| -# preConfigure = '' |
183 |
| -# export CFLAGS="-I${supabase-groonga}/include -I${postgresql}/include/server -I${supabase-groonga}/include/groonga" |
184 |
| -# export CPPFLAGS="$CFLAGS" |
185 |
| -# export LDFLAGS="-L${supabase-groonga}/lib -L${postgresql}/lib" |
186 |
| - |
187 |
| -# # Remove the problematic /EHsc flag |
188 |
| -# export CFLAGS="$(echo $CFLAGS | sed 's/-EHsc//g')" |
189 |
| -# export CXXFLAGS="$(echo $CXXFLAGS | sed 's/-EHsc//g')" |
190 |
| - |
191 |
| -# # Ensure CMake doesn't add it back |
192 |
| -# substituteInPlace CMakeLists.txt --replace "-EHsc" "" |
| 92 | +# runHook postInstall |
193 | 93 | # '';
|
194 | 94 |
|
195 |
| -# installPhase = '' |
196 |
| -# install -D pgroonga${postgresql.dlSuffix} -t $out/lib/ |
197 |
| -# install -D pgroonga.control -t $out/share/postgresql/extension |
198 |
| -# install -D data/pgroonga-*.sql -t $out/share/postgresql/extension |
199 |
| -# install -D pgroonga_database${postgresql.dlSuffix} -t $out/lib/ |
200 |
| -# install -D pgroonga_database.control -t $out/share/postgresql/extension |
201 |
| -# install -D data/pgroonga_database-*.sql -t $out/share/postgresql/extension |
| 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 |
202 | 99 | # '';
|
| 100 | + |
203 | 101 | # meta = with lib; {
|
204 | 102 | # description = "A PostgreSQL extension to use Groonga as the index";
|
205 | 103 | # longDescription = ''
|
|
216 | 114 | # };
|
217 | 115 | # }
|
218 | 116 |
|
219 |
| -{ lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, callPackage |
220 |
| -, makeWrapper, mecab }: |
221 |
| - |
| 117 | +{ lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, callPackage, mecab, makeWrapper }: |
222 | 118 | let
|
223 | 119 | supabase-groonga = callPackage ../supabase-groonga.nix { };
|
224 |
| - mecab-naist-jdic = callPackage ./mecab-naist-jdic { }; |
225 |
| -in stdenv.mkDerivation rec { |
| 120 | +in |
| 121 | +stdenv.mkDerivation rec { |
226 | 122 | pname = "pgroonga";
|
227 | 123 | version = "3.0.7";
|
228 | 124 | src = fetchurl {
|
229 |
| - url = |
230 |
| - "https://packages.groonga.org/source/${pname}/${pname}-${version}.tar.gz"; |
| 125 | + url = "https://packages.groonga.org/source/${pname}/${pname}-${version}.tar.gz"; |
231 | 126 | sha256 = "sha256-iF/zh4zDDpAw5fxW1WG8i2bfPt4VYsnYArwOoE/lwgM=";
|
232 | 127 | };
|
233 | 128 | nativeBuildInputs = [ pkg-config makeWrapper ];
|
234 |
| - buildInputs = [ postgresql msgpack-c supabase-groonga mecab mecab-naist-jdic ]; |
| 129 | + buildInputs = [ postgresql msgpack-c supabase-groonga mecab ]; |
| 130 | + |
| 131 | + configureFlags = [ |
| 132 | + "--with-mecab=${mecab}" |
| 133 | + "--enable-mecab" |
| 134 | + "--with-groonga=${supabase-groonga}" |
| 135 | + "--with-groonga-plugin-dir=${supabase-groonga}/lib/groonga/plugins" |
| 136 | + ]; |
| 137 | + |
235 | 138 | makeFlags = [
|
236 |
| - "USE_PGXS=1" |
237 | 139 | "HAVE_MSGPACK=1"
|
238 | 140 | "MSGPACK_PACKAGE_NAME=msgpack-c"
|
239 | 141 | "HAVE_MECAB=1"
|
240 |
| - "POSTGRES_INCLUDEDIR=${postgresql}/include" |
241 |
| - "POSTGRES_LIBDIR=${postgresql.lib}/lib" |
242 |
| - "PG_CONFIG=${postgresql}/bin/pg_config" |
243 |
| - "MECAB_CONFIG=${mecab}/bin/mecab-config" |
244 | 142 | ];
|
245 |
| - |
246 |
| - preConfigure = '' |
247 |
| - export MECAB_DICDIR=${mecab-naist-jdic}/lib/mecab/dic/naist-jdic |
248 |
| - export GROONGA_INCLUDE_PATH=${supabase-groonga}/include |
249 |
| - export GROONGA_LIB_PATH=${supabase-groonga}/lib |
250 |
| - export MECAB_INCLUDE_PATH=${mecab}/include |
251 |
| - export MECAB_LIB_PATH=${mecab}/lib |
252 |
| - ''; |
253 | 143 |
|
254 |
| - buildPhase = '' |
255 |
| - runHook preBuild |
256 |
| - make $makeFlags |
257 |
| - runHook postBuild |
| 144 | + preConfigure = '' |
| 145 | + export GROONGA_LIBS="-L${supabase-groonga}/lib -lgroonga" |
| 146 | + export GROONGA_CFLAGS="-I${supabase-groonga}/include" |
| 147 | + export MECAB_CONFIG="${mecab}/bin/mecab-config" |
258 | 148 | '';
|
259 | 149 |
|
260 | 150 | installPhase = ''
|
261 |
| - runHook preInstall |
262 |
| - make $makeFlags install DESTDIR=$out |
| 151 | + mkdir -p $out/lib $out/share/postgresql/extension $out/bin |
263 | 152 | install -D pgroonga${postgresql.dlSuffix} -t $out/lib/
|
264 | 153 | install -D pgroonga.control -t $out/share/postgresql/extension
|
265 | 154 | install -D data/pgroonga-*.sql -t $out/share/postgresql/extension
|
266 | 155 | install -D pgroonga_database${postgresql.dlSuffix} -t $out/lib/
|
267 | 156 | install -D pgroonga_database.control -t $out/share/postgresql/extension
|
268 | 157 | install -D data/pgroonga_database-*.sql -t $out/share/postgresql/extension
|
269 |
| - |
270 |
| - for component in pgroonga_check pgroonga_wal_applier pgroonga_crash_safer pgroonga_standby_maintainer; do |
271 |
| - if [ -f "$component${postgresql.dlSuffix}" ]; then |
272 |
| - install -D "$component${postgresql.dlSuffix}" -t $out/lib/ |
273 |
| - fi |
274 |
| - done |
275 |
| - runHook postInstall |
| 158 | +
|
| 159 | + cat << EOF > $out/share/postgresql/extension/pgroonga_set_paths.sql |
| 160 | + DO \$\$ |
| 161 | + BEGIN |
| 162 | + 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 | + END \$\$; |
| 165 | +EOF |
| 166 | + chmod +x $out/share/postgresql/extension/pgroonga_set_paths.sql |
| 167 | +
|
| 168 | + makeWrapper ${postgresql}/bin/postgres $out/bin/pgroonga-postgres \ |
| 169 | + --set LD_LIBRARY_PATH "${lib.makeLibraryPath buildInputs}:${supabase-groonga}/lib:$out/lib" |
| 170 | +
|
| 171 | + echo "Debug: Groonga plugins directory contents:" |
| 172 | + ls -l ${supabase-groonga}/lib/groonga/plugins/tokenizers/ |
276 | 173 | '';
|
277 | 174 |
|
278 | 175 | postFixup = ''
|
279 | 176 | for f in $out/lib/*.so; do
|
280 |
| - patchelf --set-rpath "${lib.makeLibraryPath buildInputs}:$out/lib" $f |
| 177 | + patchelf --set-rpath "${lib.makeLibraryPath buildInputs}:${supabase-groonga}/lib:$out/lib:${supabase-groonga}/lib/groonga/plugins/tokenizers" $f |
281 | 178 | done
|
282 | 179 | '';
|
283 | 180 |
|
|
0 commit comments