116
116
./nix/ext/pg_cron.nix
117
117
./nix/ext/pgsql-http.nix
118
118
./nix/ext/pg_plan_filter.nix
119
- # ./nix/ext/pg_net.nix
119
+ ./nix/ext/pg_net.nix
120
120
./nix/ext/pg_hashids.nix
121
121
./nix/ext/pgsodium.nix
122
122
./nix/ext/pg_graphql.nix
@@ -273,7 +273,6 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
273
273
orioledbPsqlExtensions ;
274
274
ourExts = map ( ext : { name = ext . pname ; version = ext . version ; } ) ( makeOurOrioleDbPostgresPkgs version patchedPostgres ) ;
275
275
276
- # Create the scope and new self/super for package resolution
277
276
scope = {
278
277
inherit ( patchedPostgres ) jitSupport ;
279
278
inherit ( oriole_pkgs . llvmPackages ) llvm ;
@@ -283,12 +282,10 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
283
282
newSelf = self // scope ;
284
283
newSuper = { callPackage = oriole_pkgs . newScope ( scope // postgresql . pkgs ) ; } ;
285
284
286
- # Get the packages using the passthru pattern
287
285
selectedPackages =
288
286
( map ( ext : postgresql . pkgs . "${ ext } " ) orioledbPsqlExtensions ) ++
289
287
( makeOurOrioleDbPostgresPkgs version postgresql ) ;
290
288
291
- # Build the environment with the selected packages
292
289
pgbin = oriole_pkgs . buildEnv {
293
290
name = "postgresql-and-plugins-${ postgresql . version } " ;
294
291
paths = [ postgresql ] ++ selectedPackages ;
@@ -299,18 +296,56 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
299
296
} ;
300
297
301
298
postBuild = ''
299
+ # Ensure all necessary directories exist
302
300
mkdir -p $out/bin
301
+ mkdir -p $out/lib/postgresql
302
+ mkdir -p $out/share/postgresql/extension
303
+
304
+ # Create proper links for all binaries with environment
303
305
for bin in ${ postgresql } /bin/*; do
304
- ln -sf $bin $out/bin/
306
+ binary_name=$(basename $bin)
307
+ rm -f "$out/bin/$binary_name"
308
+ makeWrapper $bin $out/bin/$binary_name \
309
+ --set POSTGRES_MAJOR_VERSION "${ postgresql . psqlSchema } " \
310
+ --prefix PATH : $out/bin \
311
+ --prefix LD_LIBRARY_PATH : "$out/lib:$out/lib/postgresql" \
312
+ --prefix PKG_CONFIG_PATH : "$out/lib/pkgconfig" \
313
+ --set PGDATA "/var/lib/postgresql/${ postgresql . psqlSchema } " \
314
+ --set PGHOST "/run/postgresql"
315
+ done
316
+
317
+ # Ensure extension files are properly linked
318
+ for pkg in ${ postgresql } ${ toString selectedPackages } ; do
319
+ # Link shared objects
320
+ if [ -d "$pkg/lib" ]; then
321
+ find "$pkg/lib" -type f -name '*.so' -exec ln -sf {} "$out/lib/postgresql/" \;
322
+ fi
323
+
324
+ # Link extension control and SQL files
325
+ if [ -d "$pkg/share/postgresql/extension" ]; then
326
+ find "$pkg/share/postgresql/extension" -type f \( -name '*.control' -o -name '*.sql' \) \
327
+ -exec ln -sf {} "$out/share/postgresql/extension/" \;
328
+ fi
305
329
done
306
-
307
- rm -f $out/bin/postgres
308
- makeWrapper ${ postgresql } /bin/postgres $out/bin/postgres \
309
- --set POSTGRES_MAJOR_VERSION "${ postgresql . psqlSchema } " \
310
- --prefix PATH : $out/bin \
311
- --prefix LD_LIBRARY_PATH : $out/lib
330
+
331
+ # Create pg_config if it doesn't exist
332
+ if [ ! -e "$out/bin/pg_config" ]; then
333
+ makeWrapper ${ postgresql } /bin/pg_config $out/bin/pg_config \
334
+ --set prefix "$out" \
335
+ --set includedir "$out/include" \
336
+ --set pkgincludedir "$out/include/postgresql" \
337
+ --set includedir-server "$out/include/postgresql/server" \
338
+ --set libdir "$out/lib" \
339
+ --set pkglibdir "$out/lib/postgresql" \
340
+ --set localedir "$out/share/locale" \
341
+ --set mandir "$out/share/man" \
342
+ --set sharedir "$out/share/postgresql" \
343
+ --set sysconfdir "/etc/postgresql" \
344
+ --set pgxs "$out/lib/postgresql/pgxs/src/makefiles/pgxs.mk" \
345
+ --set configure "--enable-nls --with-openssl --with-libxml --with-libxslt"
346
+ fi
312
347
'' ;
313
- } // {
348
+ } // {
314
349
version = postgresql . version ;
315
350
} ;
316
351
in
0 commit comments