Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion docker/nix/build_nix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ nix --version
if [ -d "/workspace" ]; then
cd /workspace
fi
nix build .#checks.$(nix-instantiate --eval -E builtins.currentSystem | tr -d '"').psql_15 -L --no-link
nix build .#checks.$(nix-instantiate --eval -E builtins.currentSystem | tr -d '"').psql_16 -L --no-link
nix build .#psql_15/bin -o psql_15
nix flake check -L
nix build .#psql_16/bin -o psql_16
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_15
nix copy --to s3://nix-postgres-artifacts?secret-key=nix-secret-key ./psql_16
35 changes: 30 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@
# Define the available PostgreSQL versions
postgresVersions = {
psql_15 = makePostgres "15";
# Uncomment the line below to enable PostgreSQL 16
# psql_16 = makePostgres "16";
psql_16 = makePostgres "16";
# psql_orioledb_16 = makeOrioleDbPostgres "16_23" postgresql_orioledb_16;
};

Expand All @@ -307,15 +306,17 @@
postgresql = postgresqlPackage;
};
postgresql_15 = getPostgresqlPackage "15";
postgresql_16 = getPostgresqlPackage "16";
in
postgresVersions //{
supabase-groonga = supabase-groonga;
# PostgreSQL versions.
psql_15 = makePostgres "15";
psql_15 = postgresVersions.psql_15;
psql_16 = postgresVersions.psql_16;
#psql_orioledb_16 = makeOrioleDbPostgres "16_23" postgresql_orioledb_16;
sfcgal = sfcgal;
pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP;
inherit postgresql_15;
inherit postgresql_15 postgresql_16;
postgresql_15_debug = if pkgs.stdenv.isLinux then postgresql_15.debug else null;
postgresql_15_src = pkgs.stdenv.mkDerivation {
pname = "postgresql-15-src";
Expand All @@ -339,6 +340,28 @@
platforms = platforms.all;
};
};
postgresql_16_src = pkgs.stdenv.mkDerivation {
pname = "postgresql-16-src";
version = postgresql_16.version;

src = postgresql_16.src;

nativeBuildInputs = [ pkgs.bzip2 ];

phases = [ "unpackPhase" "installPhase" ];

installPhase = ''
mkdir -p $out
cp -r . $out
'';

meta = with pkgs.lib; {
description = "PostgreSQL 15 source files";
homepage = "https://www.postgresql.org/";
license = licenses.postgresql;
platforms = platforms.all;
};
};
mecab_naist_jdic = mecab-naist-jdic;
supabase_groonga = supabase-groonga;
pg_regress = makePgRegress activeVersion;
Expand Down Expand Up @@ -397,6 +420,7 @@
--subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \
--subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' \
--subst-var-by 'PSQL_CONF_FILE' $out/etc/postgresql/postgresql.conf \
--subst-var-by 'PSQL16_BINDIR' '${basePackages.psql_16.bin}' \
--subst-var-by 'PGSODIUM_GETKEY' '${getkeyScript}' \
--subst-var-by 'READREPL_CONF_FILE' "$out/etc/postgresql-custom/read-replica.conf" \
--subst-var-by 'LOGGING_CONF_FILE' "$out/etc/postgresql-custom/logging.conf" \
Expand Down Expand Up @@ -425,6 +449,7 @@
--subst-var-by 'PGSQL_DEFAULT_PORT' '${pgsqlDefaultPort}' \
--subst-var-by 'PGSQL_SUPERUSER' '${pgsqlSuperuser}' \
--subst-var-by 'PSQL15_BINDIR' '${basePackages.psql_15.bin}' \
--subst-var-by 'PSQL16_BINDIR' '${basePackages.psql_16.bin}' \
--subst-var-by 'MIGRATIONS_DIR' '${migrationsDir}' \
--subst-var-by 'POSTGRESQL_SCHEMA_SQL' '${postgresqlSchemaSql}' \
--subst-var-by 'PGBOUNCER_AUTH_SCHEMA_SQL' '${pgbouncerAuthSchemaSql}' \
Expand Down Expand Up @@ -569,7 +594,7 @@
# flake check'. This is run in the CI system, as well.
checks = {
psql_15 = makeCheckHarness basePackages.psql_15.bin;
#psql_16 = makeCheckHarness basePackages.psql_16.bin;
psql_16 = makeCheckHarness basePackages.psql_16.bin;
#psql_orioledb_16 = makeCheckHarness basePackages.psql_orioledb_16.bin;
};

Expand Down
2 changes: 1 addition & 1 deletion nix/ext/hypopg.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pg_backtrace.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pg_cron.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pg_hashids.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pg_net.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp sql/*.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pg_plan_filter.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
'';

Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pg_stat_monitor.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pg_tle.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
33 changes: 31 additions & 2 deletions nix/ext/pgrouting.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,38 @@ stdenv.mkDerivation rec {
hash = "sha256-QC77AnPGpPQGEWi6JtJdiNsB2su5+aV2pKg5ImR2B0k=";
};

#disable compile time warnings for incompatible pointer types only on macos and pg16
NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16")
"-Wno-error=int-conversion -Wno-error=incompatible-pointer-types";

cmakeFlags = [
"-DPOSTGRESQL_VERSION=${postgresql.version}"
] ++ lib.optionals (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") [
"-DCMAKE_MACOSX_RPATH=ON"
"-DCMAKE_SHARED_MODULE_SUFFIX=.dylib"
"-DCMAKE_SHARED_LIBRARY_SUFFIX=.dylib"
];

preConfigure = lib.optionalString (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") ''
export DLSUFFIX=.dylib
export CMAKE_SHARED_LIBRARY_SUFFIX=.dylib
export CMAKE_SHARED_MODULE_SUFFIX=.dylib
export MACOSX_RPATH=ON
'';

postBuild = lib.optionalString (stdenv.isDarwin && lib.versionAtLeast postgresql.version "16") ''
shopt -s nullglob
for file in lib/libpgrouting-*.so; do
if [ -f "$file" ]; then
mv "$file" "''${file%.so}.dylib"
fi
done
shopt -u nullglob
'';

installPhase = ''
install -D lib/*.so -t $out/lib
install -D sql/pgrouting--${version}.sql -t $out/share/postgresql/extension
install -D lib/*${postgresql.dlSuffix} -t $out/lib
install -D sql/pgrouting--*.sql -t $out/share/postgresql/extension
install -D sql/common/pgrouting.control -t $out/share/postgresql/extension
'';

Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pgsodium.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp sql/*.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pgsql-http.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp *.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/ext/pgvector.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/{lib,share/postgresql/extension}

cp *.so $out/lib
cp *${postgresql.dlSuffix} $out/lib
cp sql/*.sql $out/share/postgresql/extension
cp *.control $out/share/postgresql/extension
'';
Expand Down
76 changes: 6 additions & 70 deletions nix/ext/plv8.nix
Original file line number Diff line number Diff line change
Expand Up @@ -105,86 +105,22 @@ stdenv.mkDerivation (finalAttrs: {
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"

${lib.optionalString stdenv.isDarwin ''
install_name_tool -add_rpath "${v8}/lib" $out/lib/plv8-${finalAttrs.version}.so
install_name_tool -add_rpath "${postgresql}/lib" $out/lib/plv8-${finalAttrs.version}.so
install_name_tool -add_rpath "${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}.so
install_name_tool -change @rpath/libv8_monolith.dylib ${v8}/lib/libv8_monolith.dylib $out/lib/plv8-${finalAttrs.version}.so
install_name_tool -add_rpath "${v8}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
install_name_tool -add_rpath "${postgresql}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
install_name_tool -add_rpath "${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
install_name_tool -change @rpath/libv8_monolith.dylib ${v8}/lib/libv8_monolith.dylib $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
''}

${lib.optionalString (!stdenv.isDarwin) ''
${patchelf}/bin/patchelf --set-rpath "${v8}/lib:${postgresql}/lib:${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}.so
${patchelf}/bin/patchelf --set-rpath "${v8}/lib:${postgresql}/lib:${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}${postgresql.dlSuffix}
''}
'';

passthru = {
tests =
let
postgresqlWithSelf = postgresql.withPackages (_: [
finalAttrs.finalPackage
]);
in {
smoke = runCommand "plv8-smoke-test" {} ''
export PATH=${lib.makeBinPath [
postgresqlWithSelf
coreutils
gnugrep
]}
db="$PWD/testdb"
initdb "$db"
postgres -k "$db" -D "$db" &
pid="$!"

for i in $(seq 1 100); do
if psql -h "$db" -d postgres -c "" 2>/dev/null; then
break
elif ! kill -0 "$pid"; then
exit 1
else
sleep 0.1
fi
done

psql -h "$db" -d postgres -c 'CREATE EXTENSION plv8; DO $$ plv8.elog(NOTICE, plv8.version); $$ LANGUAGE plv8;' 2> "$out"
grep -q "${finalAttrs.version}" "$out"
kill -0 "$pid"
'';

regression = stdenv.mkDerivation {
name = "plv8-regression";
inherit (finalAttrs) src patches nativeBuildInputs buildInputs dontConfigure;

buildPhase = ''
runHook preBuild

# The regression tests need to be run in the order specified in the Makefile.
echo -e "include Makefile\nprint_regress_files:\n\t@echo \$(REGRESS)" > Makefile.regress
REGRESS_TESTS=$(make -f Makefile.regress print_regress_files)

${postgresql}/lib/pgxs/src/test/regress/pg_regress \
--bindir='${postgresqlWithSelf}/bin' \
--temp-instance=regress-instance \
--dbname=contrib_regression \
$REGRESS_TESTS

runHook postBuild
'';

installPhase = ''
runHook preInstall

touch "$out"

runHook postInstall
'';
};
};
};

meta = with lib; {
description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL";
homepage = "https://plv8.github.io/";
maintainers = with maintainers; [ samrose ];
platforms = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
license = licenses.postgresql;
};
})
})
2 changes: 1 addition & 1 deletion nix/ext/supautils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ stdenv.mkDerivation rec {
installPhase = ''
mkdir -p $out/lib

install -D supautils.so -t $out/lib
install -D *${postgresql.dlSuffix} -t $out/lib
'';

meta = with lib; {
Expand Down
4 changes: 4 additions & 0 deletions nix/postgresql/16.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ./generic.nix {
version = "16.3";
hash = "sha256-Mxlj1dPcTK9CFqBJ+kC2bWvLjHMGFYWUEblRh2TmBYU=";
}
1 change: 1 addition & 0 deletions nix/postgresql/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ let
#adapted from the postgresql nixpkgs package
versions = {
postgresql_15 = ./15.nix;
postgresql_16 = ./16.nix;
};

mkAttributes = jitSupport:
Expand Down
Loading
Loading