Skip to content

Commit 99f238e

Browse files
committed
feat: build and flake check of pg 16.3 with exts/wrappers
1 parent f7bb3fe commit 99f238e

18 files changed

+96
-89
lines changed

flake.nix

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,7 @@
290290
# Define the available PostgreSQL versions
291291
postgresVersions = {
292292
psql_15 = makePostgres "15";
293-
# Uncomment the line below to enable PostgreSQL 16
294-
# psql_16 = makePostgres "16";
293+
psql_16 = makePostgres "16";
295294
# psql_orioledb_16 = makeOrioleDbPostgres "16_23" postgresql_orioledb_16;
296295
};
297296

@@ -307,15 +306,17 @@
307306
postgresql = postgresqlPackage;
308307
};
309308
postgresql_15 = getPostgresqlPackage "15";
309+
postgresql_16 = getPostgresqlPackage "16";
310310
in
311311
postgresVersions //{
312312
supabase-groonga = supabase-groonga;
313313
# PostgreSQL versions.
314-
psql_15 = makePostgres "15";
314+
psql_15 = postgresVersions.psql_15;
315+
psql_16 = postgresVersions.psql_16;
315316
#psql_orioledb_16 = makeOrioleDbPostgres "16_23" postgresql_orioledb_16;
316317
sfcgal = sfcgal;
317318
pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP;
318-
inherit postgresql_15;
319+
inherit postgresql_15 postgresql_16;
319320
postgresql_15_debug = if pkgs.stdenv.isLinux then postgresql_15.debug else null;
320321
postgresql_15_src = pkgs.stdenv.mkDerivation {
321322
pname = "postgresql-15-src";
@@ -339,6 +340,28 @@
339340
platforms = platforms.all;
340341
};
341342
};
343+
postgresql_16_src = pkgs.stdenv.mkDerivation {
344+
pname = "postgresql-16-src";
345+
version = postgresql_16.version;
346+
347+
src = postgresql_16.src;
348+
349+
nativeBuildInputs = [ pkgs.bzip2 ];
350+
351+
phases = [ "unpackPhase" "installPhase" ];
352+
353+
installPhase = ''
354+
mkdir -p $out
355+
cp -r . $out
356+
'';
357+
358+
meta = with pkgs.lib; {
359+
description = "PostgreSQL 15 source files";
360+
homepage = "https://www.postgresql.org/";
361+
license = licenses.postgresql;
362+
platforms = platforms.all;
363+
};
364+
};
342365
mecab_naist_jdic = mecab-naist-jdic;
343366
supabase_groonga = supabase-groonga;
344367
pg_regress = makePgRegress activeVersion;
@@ -397,6 +420,7 @@
397420
--subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \
398421
--subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' \
399422
--subst-var-by 'PSQL_CONF_FILE' $out/etc/postgresql/postgresql.conf \
423+
--subst-var-by 'PSQL16_BINDIR' '${basePackages.psql_16.bin}' \
400424
--subst-var-by 'PGSODIUM_GETKEY' '${getkeyScript}' \
401425
--subst-var-by 'READREPL_CONF_FILE' "$out/etc/postgresql-custom/read-replica.conf" \
402426
--subst-var-by 'LOGGING_CONF_FILE' "$out/etc/postgresql-custom/logging.conf" \
@@ -425,6 +449,7 @@
425449
--subst-var-by 'PGSQL_DEFAULT_PORT' '${pgsqlDefaultPort}' \
426450
--subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \
427451
--subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' \
452+
--subst-var-by 'PSQL16_BINDIR' '${basePackages.psql_16.bin}' \
428453
--subst-var-by 'MIGRATIONS_DIR' '${migrationsDir}' \
429454
--subst-var-by 'POSTGRESQL_SCHEMA_SQL' '${postgresqlSchemaSql}' \
430455
--subst-var-by 'PGBOUNCER_AUTH_SCHEMA_SQL' '${pgbouncerAuthSchemaSql}' \
@@ -569,7 +594,7 @@
569594
# flake check'. This is run in the CI system, as well.
570595
checks = {
571596
psql_15 = makeCheckHarness basePackages.psql_15.bin;
572-
#psql_16 = makeCheckHarness basePackages.psql_16.bin;
597+
psql_16 = makeCheckHarness basePackages.psql_16.bin;
573598
#psql_orioledb_16 = makeCheckHarness basePackages.psql_orioledb_16.bin;
574599
};
575600

nix/ext/hypopg.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
1616
installPhase = ''
1717
mkdir -p $out/{lib,share/postgresql/extension}
1818
19-
cp *.so $out/lib
19+
cp *${postgresql.dlSuffix} $out/lib
2020
cp *.sql $out/share/postgresql/extension
2121
cp *.control $out/share/postgresql/extension
2222
'';

nix/ext/pg_backtrace.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
1818
installPhase = ''
1919
mkdir -p $out/{lib,share/postgresql/extension}
2020
21-
cp *.so $out/lib
21+
cp *${postgresql.dlSuffix} $out/lib
2222
cp *.sql $out/share/postgresql/extension
2323
cp *.control $out/share/postgresql/extension
2424
'';

nix/ext/pg_cron.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
1616
installPhase = ''
1717
mkdir -p $out/{lib,share/postgresql/extension}
1818
19-
cp *.so $out/lib
19+
cp *${postgresql.dlSuffix} $out/lib
2020
cp *.sql $out/share/postgresql/extension
2121
cp *.control $out/share/postgresql/extension
2222
'';

nix/ext/pg_hashids.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
1616
installPhase = ''
1717
mkdir -p $out/{lib,share/postgresql/extension}
1818
19-
cp *.so $out/lib
19+
cp *${postgresql.dlSuffix} $out/lib
2020
cp *.sql $out/share/postgresql/extension
2121
cp *.control $out/share/postgresql/extension
2222
'';

nix/ext/pg_net.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
1818
installPhase = ''
1919
mkdir -p $out/{lib,share/postgresql/extension}
2020
21-
cp *.so $out/lib
21+
cp *${postgresql.dlSuffix} $out/lib
2222
cp sql/*.sql $out/share/postgresql/extension
2323
cp *.control $out/share/postgresql/extension
2424
'';

nix/ext/pg_plan_filter.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
1616
installPhase = ''
1717
mkdir -p $out/{lib,share/postgresql/extension}
1818
19-
cp *.so $out/lib
19+
cp *${postgresql.dlSuffix} $out/lib
2020
cp *.sql $out/share/postgresql/extension
2121
'';
2222

nix/ext/pg_stat_monitor.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
3333
installPhase = ''
3434
mkdir -p $out/{lib,share/postgresql/extension}
3535
36-
cp *.so $out/lib
36+
cp *${postgresql.dlSuffix} $out/lib
3737
cp *.sql $out/share/postgresql/extension
3838
cp *.control $out/share/postgresql/extension
3939
'';

nix/ext/pg_tle.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
2121
installPhase = ''
2222
mkdir -p $out/{lib,share/postgresql/extension}
2323
24-
cp *.so $out/lib
24+
cp *${postgresql.dlSuffix} $out/lib
2525
cp *.sql $out/share/postgresql/extension
2626
cp *.control $out/share/postgresql/extension
2727
'';

nix/ext/pgrouting.nix

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,38 @@ stdenv.mkDerivation rec {
1414
hash = "sha256-QC77AnPGpPQGEWi6JtJdiNsB2su5+aV2pKg5ImR2B0k=";
1515
};
1616

17+
#disable compile time warnings for incompatible pointer types only on macos and pg16
18+
NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16")
19+
"-Wno-error=int-conversion -Wno-error=incompatible-pointer-types";
20+
21+
cmakeFlags = [
22+
"-DPOSTGRESQL_VERSION=${postgresql.version}"
23+
] ++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") [
24+
"-DCMAKE_MACOSX_RPATH=ON"
25+
"-DCMAKE_SHARED_MODULE_SUFFIX=.dylib"
26+
"-DCMAKE_SHARED_LIBRARY_SUFFIX=.dylib"
27+
];
28+
29+
preConfigure = lib.optionalString (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") ''
30+
export DLSUFFIX=.dylib
31+
export CMAKE_SHARED_LIBRARY_SUFFIX=.dylib
32+
export CMAKE_SHARED_MODULE_SUFFIX=.dylib
33+
export MACOSX_RPATH=ON
34+
'';
35+
36+
postBuild = lib.optionalString (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") ''
37+
shopt -s nullglob
38+
for file in lib/libpgrouting-*.so; do
39+
if [ -f "$file" ]; then
40+
mv "$file" "''${file%.so}.dylib"
41+
fi
42+
done
43+
shopt -u nullglob
44+
'';
45+
1746
installPhase = ''
18-
install -D lib/*.so -t $out/lib
19-
install -D sql/pgrouting--${version}.sql -t $out/share/postgresql/extension
47+
install -D lib/*${postgresql.dlSuffix} -t $out/lib
48+
install -D sql/pgrouting--*.sql -t $out/share/postgresql/extension
2049
install -D sql/common/pgrouting.control -t $out/share/postgresql/extension
2150
'';
2251

0 commit comments

Comments
 (0)