Skip to content

Commit 049010a

Browse files
committed
fix: running server
1 parent 6a5648b commit 049010a

File tree

2 files changed

+48
-16
lines changed

2 files changed

+48
-16
lines changed

flake.nix

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
./nix/ext/pg_cron.nix
117117
./nix/ext/pgsql-http.nix
118118
./nix/ext/pg_plan_filter.nix
119-
#./nix/ext/pg_net.nix
119+
./nix/ext/pg_net.nix
120120
./nix/ext/pg_hashids.nix
121121
./nix/ext/pgsodium.nix
122122
./nix/ext/pg_graphql.nix
@@ -273,7 +273,6 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
273273
orioledbPsqlExtensions;
274274
ourExts = map (ext: { name = ext.pname; version = ext.version; }) (makeOurOrioleDbPostgresPkgs version patchedPostgres);
275275

276-
# Create the scope and new self/super for package resolution
277276
scope = {
278277
inherit (patchedPostgres) jitSupport;
279278
inherit (oriole_pkgs.llvmPackages) llvm;
@@ -283,12 +282,10 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
283282
newSelf = self // scope;
284283
newSuper = { callPackage = oriole_pkgs.newScope (scope // postgresql.pkgs); };
285284

286-
# Get the packages using the passthru pattern
287285
selectedPackages =
288286
(map (ext: postgresql.pkgs."${ext}") orioledbPsqlExtensions) ++
289287
(makeOurOrioleDbPostgresPkgs version postgresql);
290288

291-
# Build the environment with the selected packages
292289
pgbin = oriole_pkgs.buildEnv {
293290
name = "postgresql-and-plugins-${postgresql.version}";
294291
paths = [ postgresql ] ++ selectedPackages;
@@ -299,18 +296,56 @@ makeOrioleDbPostgresBin = version: patchedPostgres:
299296
};
300297

301298
postBuild = ''
299+
# Ensure all necessary directories exist
302300
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
303305
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
305329
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
312347
'';
313-
}// {
348+
} // {
314349
version = postgresql.version;
315350
};
316351
in

nix/tools/run-server.sh.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,8 @@ session_preload_libraries = 'supautils'" \
6464

6565
remove_config_items() {
6666
if [ "$1" == "orioledb-16" ]; then
67-
# Remove items from supautils.conf
68-
sed -i '/supautils.privileged_extensions/d' "$DATDIR/supautils.conf"
69-
7067
# Remove items from postgresql.conf
71-
sed -i 's/ timescaledb,//g' "$DATDIR/postgresql.conf"
68+
sed -i 's/ timescaledb,//g;' "$DATDIR/postgresql.conf"
7269
sed -i 's/ timescaledb,//g; s/ vector,//g; s/ plv8,//g; s/ postgis,//g; s/ pgrouting,//g' "$DATDIR/supautils.conf"
7370
fi
7471
}

0 commit comments

Comments
 (0)