From 626f6047a2eca2d038882e0778368a61ff5d3e19 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 17 Sep 2024 21:55:33 +0200 Subject: [PATCH] postgresqlPackages: replace custom installPhase with buildPostgresqlExtension helper --- .../sql/postgresql/buildPostgresExtension.nix | 129 ++++++++++++++++++ pkgs/servers/sql/postgresql/ext/age.nix | 12 +- .../servers/sql/postgresql/ext/anonymizer.nix | 15 +- .../postgresql/ext/apache_datasketches.nix | 31 +---- pkgs/servers/sql/postgresql/ext/citus.nix | 18 +-- .../servers/sql/postgresql/ext/cstore_fdw.nix | 13 +- pkgs/servers/sql/postgresql/ext/h3-pg.nix | 11 +- pkgs/servers/sql/postgresql/ext/hypopg.nix | 12 +- .../sql/postgresql/ext/jsonb_deep_sum.nix | 14 +- pkgs/servers/sql/postgresql/ext/lantern.nix | 17 +-- pkgs/servers/sql/postgresql/ext/periods.nix | 12 +- .../sql/postgresql/ext/pg_auto_failover.nix | 13 +- pkgs/servers/sql/postgresql/ext/pg_bigm.nix | 12 +- pkgs/servers/sql/postgresql/ext/pg_cron.nix | 14 +- .../servers/sql/postgresql/ext/pg_ed25519.nix | 15 +- .../sql/postgresql/ext/pg_embedding.nix | 12 +- .../sql/postgresql/ext/pg_hint_plan.nix | 12 +- pkgs/servers/sql/postgresql/ext/pg_hll.nix | 12 +- pkgs/servers/sql/postgresql/ext/pg_ivm.nix | 12 +- .../sql/postgresql/ext/pg_libversion.nix | 14 +- pkgs/servers/sql/postgresql/ext/pg_net.nix | 14 +- .../servers/sql/postgresql/ext/pg_partman.nix | 15 +- .../sql/postgresql/ext/pg_rational.nix | 17 +-- .../sql/postgresql/ext/pg_relusage.nix | 12 +- pkgs/servers/sql/postgresql/ext/pg_repack.nix | 11 +- .../sql/postgresql/ext/pg_roaringbitmap.nix | 14 +- .../sql/postgresql/ext/pg_safeupdate.nix | 10 +- .../sql/postgresql/ext/pg_similarity.nix | 13 +- .../servers/sql/postgresql/ext/pg_squeeze.nix | 18 +-- pkgs/servers/sql/postgresql/ext/pg_topn.nix | 14 +- pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix | 10 +- pkgs/servers/sql/postgresql/ext/pgaudit.nix | 12 +- pkgs/servers/sql/postgresql/ext/pgjwt.nix | 10 +- pkgs/servers/sql/postgresql/ext/pgmq.nix | 14 +- pkgs/servers/sql/postgresql/ext/pgroonga.nix | 16 +-- pkgs/servers/sql/postgresql/ext/pgrouting.nix | 12 +- pkgs/servers/sql/postgresql/ext/pgsodium.nix | 14 +- .../servers/sql/postgresql/ext/pgsql-http.nix | 12 +- pkgs/servers/sql/postgresql/ext/pgtap.nix | 7 +- pkgs/servers/sql/postgresql/ext/pgvector.nix | 12 +- .../sql/postgresql/ext/plpgsql_check.nix | 12 +- pkgs/servers/sql/postgresql/ext/plr.nix | 11 +- .../sql/postgresql/ext/plv8/default.nix | 17 +-- pkgs/servers/sql/postgresql/ext/postgis.nix | 29 ++-- pkgs/servers/sql/postgresql/ext/repmgr.nix | 14 +- pkgs/servers/sql/postgresql/ext/rum.nix | 11 +- pkgs/servers/sql/postgresql/ext/smlar.nix | 12 +- .../sql/postgresql/ext/system_stats.nix | 17 +-- pkgs/servers/sql/postgresql/ext/tds_fdw.nix | 13 +- .../sql/postgresql/ext/temporal_tables.nix | 12 +- .../sql/postgresql/ext/timescaledb.nix | 6 +- .../sql/postgresql/ext/tsearch_extras.nix | 11 +- pkgs/servers/sql/postgresql/ext/tsja.nix | 1 - pkgs/servers/sql/postgresql/ext/wal2json.nix | 10 +- pkgs/servers/sql/postgresql/generic.nix | 1 + 55 files changed, 263 insertions(+), 571 deletions(-) create mode 100644 pkgs/servers/sql/postgresql/buildPostgresExtension.nix diff --git a/pkgs/servers/sql/postgresql/buildPostgresExtension.nix b/pkgs/servers/sql/postgresql/buildPostgresExtension.nix new file mode 100644 index 00000000000000..af4a06c589c9c3 --- /dev/null +++ b/pkgs/servers/sql/postgresql/buildPostgresExtension.nix @@ -0,0 +1,129 @@ +# PostgreSQL's build system for extensions (PGXS) makes the following assumptions: +# - All extensions will be installed in the same prefix as PostgreSQL itself. +# - pg_config is able to return the correct paths for bindir/libdir/datadir etc. +# +# Both of those assumptions break with nix. Since each extension is a separate +# derivation, we need to put all its files into a different folder. At the same +# time, pg_config only points to the PostgreSQL derivation's paths. +# +# When building extensions, the paths provided by pg_config are used for two +# purposes: +# - To find postgres libs and headers and reference those paths via -L and -I flags. +# - To determine the correct install directory. +# +# The PGXS Makefiles also support an environment variable DESTDIR, which is added as +# a prefix to all install locations. This is primarily used for temporary installs +# while running the test suite. Since pg_config returns absolute paths to /nix/store +# for us, using DESTDIR will result in install locations of the form: +# $DESTIDR/nix/store//... +# +# In multiple iterations, the following approaches have been tried to work around all +# of this: +# 1. For a long time, all extensions in nixpkgs just overwrote the installPhase +# and moved the respective files to the correct location manually. This approach +# is not maintainable, because whenever upstream adds a new file, we'd have to +# make sure the file is correctly installed as well. Additionally, it makes adding +# a new extension harder than it should be. +# +# 2. A wrapper around pg_config could just replace the returned paths with paths to +# $out of currently building derivation, i.e. the extension. This works for install- +# ation, but breaks for any of the libs and headers the extension needs from postgres +# itself. +# +# 3. A variation of 2., but make the pg_config wrapper only return the changed paths +# during the installPahse. During configure and build, it would return the regular +# paths to the PostgreSQL derivation. This works better, but not for every case. +# Some extensions try to be smarter and search for the "postgres" binary to deduce +# the necessary paths from that. Those would still need special handling. +# +# 4. Use the fact that DESTDIR is prepended to every installation directory - and only +# there, to run a replacement of all Makefiles in postgres' lib/pgxs/ folder and +# all Makefiles in the extension's source. "$DESTDIR/$bindir" can be replaced with +# "$out/bin" etc. - thus mapping the installPhase directly into the right output. +# This works beautifully - for the majority of cases. But it doesn't work for +# some extensions that use CMake. And it doesn't work for some extensions that use +# custom variables instead of the default "bindir" and friends. +# +# 5. Just set DESTDIR to the extensions's output and then clean up afterward. This will +# result in paths like this: +# /nix/store//nix/store//... +# Directly after the installPhase, we'll move the files in the right folder. +# This seems to work consistently across all extensions we have in nixpkgs right now. +# Of course, it would break down for any extension that doesn't support DESTDIR - +# but that just means PGXS is not used either, so that's OK. +# +# This last approach is the one we're taking in this file. To make sure the removal of the +# nested nix/store happens immediately after the installPhase, before any other postInstall +# hooks run, this needs to be run in an override of `mkDerivation` and not in a setup hook. + +{ + lib, + stdenv, + postgresql, +}: + +args: + +let + buildPostgresExtension = finalAttrs: prevAttrs: { + buildInputs = [ postgresql ] ++ prevAttrs.buildInputs or [ ]; + + installFlags = [ + "DESTDIR=${placeholder "out"}" + ] ++ prevAttrs.installFlags or [ ]; + + postInstall = + '' + # DESTDIR + pg_config install the files into + # /nix/store//nix/store//... + # We'll now remove the /nix/store/ part: + if [[ -d "$out${postgresql}" ]]; then + cp -alt "$out" "$out${postgresql}"/* + rm -r "$out${postgresql}" + fi + + if [[ -d "$out${postgresql.dev}" ]]; then + mkdir -p "''${dev:-$out}" + cp -alt "''${dev:-$out}" "$out${postgresql.dev}"/* + rm -r "$out${postgresql.dev}" + fi + + if [[ -d "$out${postgresql.lib}" ]]; then + mkdir -p "''${lib:-$out}" + cp -alt "''${lib:-$out}" "$out${postgresql.lib}"/* + rm -r "$out${postgresql.lib}" + fi + + if [[ -d "$out${postgresql.doc}" ]]; then + mkdir -p "''${doc:-$out}" + cp -alt "''${doc:-$out}" "$out${postgresql.doc}"/* + rm -r "$out${postgresql.doc}" + fi + + if [[ -d "$out${postgresql.man}" ]]; then + mkdir -p "''${man:-$out}" + cp -alt "''${man:-$out}" "$out${postgresql.man}"/* + rm -r "$out${postgresql.man}" + fi + + # In some cases (postgis) parts of the install script + # actually work "OK", before we add DESTDIR, so some + # files end up in + # /nix/store//nix/store//... + if [[ -d "$out$out" ]]; then + cp -alt "$out" "$out$out"/* + rm -r "$out$out" + fi + + if [[ -d "$out/nix/store" ]]; then + if ! rmdir "$out/nix/store" "$out/nix"; then + find "$out/nix" + nixErrorLog 'Found left-overs in $out/nix/store, make sure to move them into $out properly.' + exit 1 + fi + fi + '' + + prevAttrs.postInstall or ""; + }; +in +stdenv.mkDerivation (lib.extends buildPostgresExtension (lib.toFunction args)) diff --git a/pkgs/servers/sql/postgresql/ext/age.nix b/pkgs/servers/sql/postgresql/ext/age.nix index b80d1c203b2c63..a224762293ec47 100644 --- a/pkgs/servers/sql/postgresql/ext/age.nix +++ b/pkgs/servers/sql/postgresql/ext/age.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, bison, fetchFromGitHub, flex, perl, postgresql }: +{ lib, stdenv, bison, fetchFromGitHub, flex, perl, postgresql, buildPostgresExtension }: let hashes = { @@ -9,7 +9,7 @@ let "12" = "sha256-JFNk17ESsIt20dwXrfBkQ5E6DbZzN/Q9eS6+WjCXGd4="; }; in -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "age"; version = "1.5.0-rc0"; @@ -20,20 +20,12 @@ stdenv.mkDerivation rec { hash = hashes.${lib.versions.major postgresql.version} or (throw "Source for Age is not available for ${postgresql.version}"); }; - buildInputs = [ postgresql ]; - makeFlags = [ "BISON=${bison}/bin/bison" "FLEX=${flex}/bin/flex" "PERL=${perl}/bin/perl" ]; - installPhase = '' - install -D -t $out/lib *${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - passthru.tests = stdenv.mkDerivation { inherit version src; diff --git a/pkgs/servers/sql/postgresql/ext/anonymizer.nix b/pkgs/servers/sql/postgresql/ext/anonymizer.nix index 4bb5aa544440eb..7e800761e92bad 100644 --- a/pkgs/servers/sql/postgresql/ext/anonymizer.nix +++ b/pkgs/servers/sql/postgresql/ext/anonymizer.nix @@ -1,23 +1,16 @@ -{ lib, stdenv, pg-dump-anon, postgresql, runtimeShell, jitSupport, llvm }: +{ lib, stdenv, pg-dump-anon, postgresql, runtimeShell, jitSupport, llvm, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "postgresql_anonymizer"; inherit (pg-dump-anon) version src passthru; - buildInputs = [ postgresql ]; nativeBuildInputs = [ postgresql ] ++ lib.optional jitSupport llvm; strictDeps = true; - makeFlags = [ - "BINDIR=${placeholder "out"}/bin" - "datadir=${placeholder "out"}/share/postgresql" - "pkglibdir=${placeholder "out"}/lib" - "DESTDIR=" - ]; - - postInstall = '' + # Needs to be after postInstall, where removeNestedNixStore runs + preFixup = '' cat >$out/bin/pg_dump_anon.sh <<'EOF' #!${runtimeShell} echo "This script is deprecated by upstream. To use the new script," diff --git a/pkgs/servers/sql/postgresql/ext/apache_datasketches.nix b/pkgs/servers/sql/postgresql/ext/apache_datasketches.nix index af3df00fca6446..fea5610b2a1b7d 100644 --- a/pkgs/servers/sql/postgresql/ext/apache_datasketches.nix +++ b/pkgs/servers/sql/postgresql/ext/apache_datasketches.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchFromGitHub, postgresql, boost182, nixosTests }: +{ stdenv, lib, fetchFromGitHub, postgresql, boost182, nixosTests, buildPostgresExtension }: let version = "1.7.0"; @@ -20,7 +20,7 @@ let }; in -stdenv.mkDerivation { +buildPostgresExtension { pname = "apache_datasketches"; inherit version; @@ -28,7 +28,7 @@ stdenv.mkDerivation { sourceRoot = main_src.name; - buildInputs = [ postgresql boost182 ]; + buildInputs = [ boost182 ]; patchPhase = '' runHook prePatch @@ -36,31 +36,6 @@ stdenv.mkDerivation { runHook postPatch ''; - installPhase = '' - runHook preInstall - install -D -m 644 ./datasketches${postgresql.dlSuffix} -t $out/lib/ - cat \ - sql/datasketches_cpc_sketch.sql \ - sql/datasketches_kll_float_sketch.sql \ - sql/datasketches_kll_double_sketch.sql \ - sql/datasketches_theta_sketch.sql \ - sql/datasketches_frequent_strings_sketch.sql \ - sql/datasketches_hll_sketch.sql \ - sql/datasketches_aod_sketch.sql \ - sql/datasketches_req_float_sketch.sql \ - sql/datasketches_quantiles_double_sketch.sql \ - > sql/datasketches--${version}.sql - install -D -m 644 ./datasketches.control -t $out/share/postgresql/extension - install -D -m 644 \ - ./sql/datasketches--${version}.sql \ - ./sql/datasketches--1.3.0--1.4.0.sql \ - ./sql/datasketches--1.4.0--1.5.0.sql \ - ./sql/datasketches--1.5.0--1.6.0.sql \ - ./sql/datasketches--1.6.0--1.7.0.sql \ - -t $out/share/postgresql/extension - runHook postInstall - ''; - passthru.tests.apache_datasketches = nixosTests.apache_datasketches; meta = { diff --git a/pkgs/servers/sql/postgresql/ext/citus.nix b/pkgs/servers/sql/postgresql/ext/citus.nix index 28d6139f0a50da..4f972ff103218d 100644 --- a/pkgs/servers/sql/postgresql/ext/citus.nix +++ b/pkgs/servers/sql/postgresql/ext/citus.nix @@ -4,9 +4,10 @@ , fetchFromGitHub , lz4 , postgresql +, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "citus"; version = "12.1.2"; @@ -20,23 +21,8 @@ stdenv.mkDerivation rec { buildInputs = [ curl lz4 - postgresql ]; - installPhase = '' - runHook preInstall - - install -D -t $out/lib src/backend/columnar/citus_columnar${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension src/backend/columnar/build/sql/*.sql - install -D -t $out/share/postgresql/extension src/backend/columnar/*.control - - install -D -t $out/lib src/backend/distributed/citus${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension src/backend/distributed/build/sql/*.sql - install -D -t $out/share/postgresql/extension src/backend/distributed/*.control - - runHook postInstall - ''; - meta = with lib; { # "Our soft policy for Postgres version compatibility is to support Citus' # latest release with Postgres' 3 latest releases." diff --git a/pkgs/servers/sql/postgresql/ext/cstore_fdw.nix b/pkgs/servers/sql/postgresql/ext/cstore_fdw.nix index c9f01190c91268..4152bb77ae588a 100644 --- a/pkgs/servers/sql/postgresql/ext/cstore_fdw.nix +++ b/pkgs/servers/sql/postgresql/ext/cstore_fdw.nix @@ -1,11 +1,10 @@ -{ lib, stdenv, fetchFromGitHub, postgresql, protobufc }: +{ lib, stdenv, fetchFromGitHub, postgresql, protobufc, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "cstore_fdw"; version = "unstable-2022-03-08"; nativeBuildInputs = [ protobufc ]; - buildInputs = [ postgresql ]; src = fetchFromGitHub { owner = "citusdata"; @@ -14,14 +13,6 @@ stdenv.mkDerivation rec { sha256 = "sha256-02wcCqs8A5ZOZX080fgcNJTQrYQctnlwnA8+YPaRTZc="; }; - installPhase = '' - mkdir -p $out/{lib,share/postgresql/extension} - - cp *.so $out/lib - cp *.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; - meta = with lib; { broken = versionAtLeast postgresql.version "14"; description = "Columnar storage for PostgreSQL"; diff --git a/pkgs/servers/sql/postgresql/ext/h3-pg.nix b/pkgs/servers/sql/postgresql/ext/h3-pg.nix index 1a0c701c770261..4769df30543e85 100644 --- a/pkgs/servers/sql/postgresql/ext/h3-pg.nix +++ b/pkgs/servers/sql/postgresql/ext/h3-pg.nix @@ -5,9 +5,10 @@ , h3_4 , postgresql , postgresqlTestExtension +, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "h3-pg"; version = "4.1.3"; @@ -32,16 +33,8 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ h3_4 - postgresql ]; - installPhase = '' - install -D -t $out/lib h3/h3.so - install -D -t $out/share/postgresql/extension h3/h3-*.sql h3/h3.control - install -D -t $out/lib h3_postgis/h3_postgis.so - install -D -t $out/share/postgresql/extension h3_postgis/h3_postgis-*.sql h3_postgis/h3_postgis.control - ''; - passthru.tests.extension = postgresqlTestExtension { inherit (finalAttrs) finalPackage; withPackages = [ "postgis" ]; diff --git a/pkgs/servers/sql/postgresql/ext/hypopg.nix b/pkgs/servers/sql/postgresql/ext/hypopg.nix index 534a21bb6d69f6..4401678d93f538 100644 --- a/pkgs/servers/sql/postgresql/ext/hypopg.nix +++ b/pkgs/servers/sql/postgresql/ext/hypopg.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql, gitUpdater }: +{ lib, stdenv, fetchFromGitHub, postgresql, gitUpdater, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "hypopg"; version = "1.4.1"; @@ -11,14 +11,6 @@ stdenv.mkDerivation rec { hash = "sha256-88uKPSnITRZ2VkelI56jZ9GWazG/Rn39QlyHKJKSKMM="; }; - buildInputs = [ postgresql ]; - - installPhase = '' - install -D -t $out/lib *${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.control - install -D -t $out/share/postgresql/extension *.sql - ''; - passthru = { updateScript = gitUpdater { ignoredVersions = "beta"; diff --git a/pkgs/servers/sql/postgresql/ext/jsonb_deep_sum.nix b/pkgs/servers/sql/postgresql/ext/jsonb_deep_sum.nix index 092212aa3de00a..cf20427c8db9de 100644 --- a/pkgs/servers/sql/postgresql/ext/jsonb_deep_sum.nix +++ b/pkgs/servers/sql/postgresql/ext/jsonb_deep_sum.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "jsonb_deep_sum"; version = "unstable-2021-12-24"; @@ -11,16 +11,6 @@ stdenv.mkDerivation rec { sha256 = "sha256-W1wNILAwTAjFPezq+grdRMA59KEnMZDz69n9xQUqdc0="; }; - buildInputs = [ postgresql ]; - - installPhase = '' - mkdir -p $out/{lib,share/postgresql/extension} - - cp *${postgresql.dlSuffix} $out/lib - cp *.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; - meta = with lib; { description = "PostgreSQL extension to easily add jsonb numeric"; homepage = "https://github.com/furstenheim/jsonb_deep_sum"; diff --git a/pkgs/servers/sql/postgresql/ext/lantern.nix b/pkgs/servers/sql/postgresql/ext/lantern.nix index 80263fc2b4a91c..5e28566466413c 100644 --- a/pkgs/servers/sql/postgresql/ext/lantern.nix +++ b/pkgs/servers/sql/postgresql/ext/lantern.nix @@ -4,9 +4,10 @@ , fetchFromGitHub , postgresql , postgresqlTestExtension +, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "postgresql-lantern"; version = "0.2.4"; @@ -22,20 +23,6 @@ stdenv.mkDerivation (finalAttrs: { cmake ]; - buildInputs = [ - postgresql - ]; - - installPhase = '' - runHook preInstall - - install -D -t $out/lib lantern${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension lantern-*.sql - install -D -t $out/share/postgresql/extension lantern.control - - runHook postInstall - ''; - cmakeFlags = [ "-DBUILD_FOR_DISTRIBUTING=ON" ]; diff --git a/pkgs/servers/sql/postgresql/ext/periods.nix b/pkgs/servers/sql/postgresql/ext/periods.nix index 422d6ddaf2b346..e90311761a1ba0 100644 --- a/pkgs/servers/sql/postgresql/ext/periods.nix +++ b/pkgs/servers/sql/postgresql/ext/periods.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "periods"; version = "1.2.2"; @@ -11,14 +11,6 @@ stdenv.mkDerivation rec { sha256 = "sha256-ezt+MtDqPM8OmJCD6oQTS644l+XHZoxuivq0PUIXOY8="; }; - buildInputs = [ postgresql ]; - - installPhase = '' - install -D -t $out/lib *${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "PostgreSQL extension implementing SQL standard functionality for PERIODs and SYSTEM VERSIONING"; homepage = "https://github.com/xocolatl/periods"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_auto_failover.nix b/pkgs/servers/sql/postgresql/ext/pg_auto_failover.nix index 42d055a029aeb3..93b2164bc62040 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_auto_failover.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_auto_failover.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_auto_failover"; version = "2.1"; @@ -11,14 +11,7 @@ stdenv.mkDerivation rec { sha256 = "sha256-OIWykfFbVskrkPG/zSmZtZjc+W956KSfIzK7f5QOqpI="; }; - buildInputs = postgresql.buildInputs ++ [ postgresql ]; - - installPhase = '' - install -D -t $out/bin src/bin/pg_autoctl/pg_autoctl - install -D -t $out/lib src/monitor/pgautofailover.so - install -D -t $out/share/postgresql/extension src/monitor/*.sql - install -D -t $out/share/postgresql/extension src/monitor/pgautofailover.control - ''; + buildInputs = postgresql.buildInputs; meta = with lib; { description = "PostgreSQL extension and service for automated failover and high-availability"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_bigm.nix b/pkgs/servers/sql/postgresql/ext/pg_bigm.nix index f47ce5694588e5..fb4560109b95ed 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_bigm.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_bigm.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, fetchpatch, postgresql }: +{ lib, stdenv, fetchFromGitHub, fetchpatch, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_bigm"; version = "1.2-20200228"; @@ -19,16 +19,8 @@ stdenv.mkDerivation rec { }) ]; - buildInputs = [ postgresql ]; - makeFlags = [ "USE_PGXS=1" ]; - installPhase = '' - install -D -t $out/lib pg_bigm${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "Text similarity measurement and index searching based on bigrams"; homepage = "https://pgbigm.osdn.jp/"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_cron.nix b/pkgs/servers/sql/postgresql/ext/pg_cron.nix index 02c6e6435ae756..d3b135c01c1212 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_cron.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_cron.nix @@ -1,11 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_cron"; version = "1.6.2"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "citusdata"; repo = pname; @@ -13,14 +11,6 @@ stdenv.mkDerivation rec { hash = "sha256-/dD1gX0+RRsBFIjSV9TVk+ppPw0Jrzssl+rRZ2qAp4w="; }; - installPhase = '' - mkdir -p $out/{lib,share/postgresql/extension} - - cp *${postgresql.dlSuffix} $out/lib - cp *.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; - meta = with lib; { description = "Run Cron jobs through PostgreSQL"; homepage = "https://github.com/citusdata/pg_cron"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_ed25519.nix b/pkgs/servers/sql/postgresql/ext/pg_ed25519.nix index 010f8f819da947..44f9a4fadeea57 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_ed25519.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_ed25519.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitLab, postgresql }: +{ lib, stdenv, fetchFromGitLab, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_ed25519"; version = "0.2"; src = fetchFromGitLab { @@ -10,17 +10,6 @@ stdenv.mkDerivation rec { sha256 = "16w3qx3wj81bzfhydl2pjhn8b1jak6h7ja9wq1kc626g0siggqi0"; }; - buildInputs = [ postgresql ]; - - installPhase = '' - mkdir -p $out/bin # For buildEnv to setup proper symlinks. See #22653 - mkdir -p $out/{lib,share/postgresql/extension} - - cp *.so $out/lib - cp *.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; - meta = with lib; { description = "PostgreSQL extension for signing and verifying ed25519 signatures"; homepage = "https://gitlab.com/dwagin/pg_ed25519"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_embedding.nix b/pkgs/servers/sql/postgresql/ext/pg_embedding.nix index 5306a619038d5b..ea49a59e91ceb1 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_embedding.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_embedding.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_embedding"; version = "0.3.6"; @@ -11,14 +11,6 @@ stdenv.mkDerivation rec { hash = "sha256-NTBxsQB8mR7e/CWwkCEyDiYhi3Nxl/aKgRBwqc0THcI="; }; - buildInputs = [ postgresql ]; - - installPhase = '' - install -D -t $out/lib *.so - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "PostgreSQL extension implementing the HNSW algorithm for vector similarity search"; homepage = "https://github.com/neondatabase/pg_embedding"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_hint_plan.nix b/pkgs/servers/sql/postgresql/ext/pg_hint_plan.nix index afc5b9fe650653..ad235ca245802f 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_hint_plan.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_hint_plan.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: let source = { @@ -24,7 +24,7 @@ let }; }.${lib.versions.major postgresql.version} or (throw "Source for pg_hint_plan is not available for ${postgresql.version}"); in -stdenv.mkDerivation { +buildPostgresExtension { pname = "pg_hint_plan"; inherit (source) version; @@ -40,14 +40,6 @@ stdenv.mkDerivation { substituteInPlace Makefile --replace "LDFLAGS+=-Wl,--build-id" "" ''; - buildInputs = [ postgresql ]; - - installPhase = '' - install -D -t $out/lib pg_hint_plan${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "Extension to tweak PostgreSQL execution plans using so-called 'hints' in SQL comments"; homepage = "https://github.com/ossc-db/pg_hint_plan"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_hll.nix b/pkgs/servers/sql/postgresql/ext/pg_hll.nix index a60601aef569a3..c0699f64f90e16 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_hll.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_hll.nix @@ -1,11 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_hll"; version = "2.18"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "citusdata"; repo = "postgresql-hll"; @@ -13,12 +11,6 @@ stdenv.mkDerivation rec { hash = "sha256-Latdxph1Ura8yKEokEjalJ+/GY+pAKOT3GXjuLprj6c="; }; - installPhase = '' - install -D -t $out/lib hll${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "HyperLogLog for PostgreSQL"; homepage = "https://github.com/citusdata/postgresql-hll"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_ivm.nix b/pkgs/servers/sql/postgresql/ext/pg_ivm.nix index 46c01251d503ea..620087fb2dbf4b 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_ivm.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_ivm.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_ivm"; version = "1.8"; @@ -11,14 +11,6 @@ stdenv.mkDerivation rec { hash = "sha256-HncWX3jx9sEvxGGMMZ9QT4tDQ4JYbkNrFw2aZHgCVE8="; }; - buildInputs = [ postgresql ]; - - installPhase = '' - install -D -t $out/lib pg_ivm${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "Materialized views with IVM (Incremental View Maintenance) for PostgreSQL"; homepage = "https://github.com/sraoss/pg_ivm"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_libversion.nix b/pkgs/servers/sql/postgresql/ext/pg_libversion.nix index b5c3ad6acab823..db51532dca9737 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_libversion.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_libversion.nix @@ -5,9 +5,10 @@ , pkg-config , postgresql , libversion +, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "pg_libversion"; version = "2.0.1"; @@ -23,20 +24,9 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = [ - postgresql libversion ]; - installPhase = '' - runHook preInstall - - install -D -t $out/lib libversion${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - - runHook postInstall - ''; - passthru.updateScript = gitUpdater { }; meta = with lib; { diff --git a/pkgs/servers/sql/postgresql/ext/pg_net.nix b/pkgs/servers/sql/postgresql/ext/pg_net.nix index a86f53eeef05f7..e7c864c6ccd8d3 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_net.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_net.nix @@ -1,10 +1,10 @@ -{ lib, stdenv, fetchFromGitHub, curl, postgresql }: +{ lib, stdenv, fetchFromGitHub, curl, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_net"; version = "0.8.0"; - buildInputs = [ curl postgresql ]; + buildInputs = [ curl ]; src = fetchFromGitHub { owner = "supabase"; @@ -15,14 +15,6 @@ stdenv.mkDerivation rec { env.NIX_CFLAGS_COMPILE = "-Wno-error"; - installPhase = '' - mkdir -p $out/{lib,share/postgresql/extension} - - cp *${postgresql.dlSuffix} $out/lib - cp sql/*.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; - meta = with lib; { description = "Async networking for Postgres"; homepage = "https://github.com/supabase/pg_net"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_partman.nix b/pkgs/servers/sql/postgresql/ext/pg_partman.nix index 87ee50411b7541..d2832c78b207a0 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_partman.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_partman.nix @@ -1,11 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_partman"; version = "5.1.0"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "pgpartman"; repo = pname; @@ -13,15 +11,6 @@ stdenv.mkDerivation rec { sha256 = "sha256-GrVOJ5ywZMyqyDroYDLdKkXDdIJSDGhDfveO/ZvrmYs="; }; - installPhase = '' - mkdir -p $out/{lib,share/postgresql/extension} - - cp src/*${postgresql.dlSuffix} $out/lib - cp updates/* $out/share/postgresql/extension - cp -r sql/* $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; - meta = with lib; { description = "Partition management extension for PostgreSQL"; homepage = "https://github.com/pgpartman/pg_partman"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_rational.nix b/pkgs/servers/sql/postgresql/ext/pg_rational.nix index df80ea49a541a4..6a615475e0d6da 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_rational.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_rational.nix @@ -2,9 +2,10 @@ , fetchFromGitHub , lib , postgresql +, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_rational"; version = "0.0.2"; @@ -15,20 +16,6 @@ stdenv.mkDerivation rec { sha256 = "sha256-Sp5wuX2nP3KGyWw7MFa11rI1CPIKIWBt8nvBSsASIEw="; }; - buildInputs = [ postgresql ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out/{lib,share/postgresql/extension} - - cp *${postgresql.dlSuffix} $out/lib - cp *.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - - runHook postInstall - ''; - meta = with lib; { description = "Precise fractional arithmetic for PostgreSQL"; homepage = "https://github.com/begriffs/pg_rational"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_relusage.nix b/pkgs/servers/sql/postgresql/ext/pg_relusage.nix index 1fe9fd3cac876c..43f5f7378043d6 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_relusage.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_relusage.nix @@ -1,11 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_relusage"; version = "0.0.1"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "adept"; repo = pname; @@ -13,12 +11,6 @@ stdenv.mkDerivation rec { sha256 = "8hJNjQ9MaBk3J9a73l+yQMwMW/F2N8vr5PO2o+5GvYs="; }; - installPhase = '' - install -D -t $out/lib *${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "pg_relusage extension for PostgreSQL: discover and log the relations used in your statements"; homepage = "https://github.com/adept/pg_relusage"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_repack.nix b/pkgs/servers/sql/postgresql/ext/pg_repack.nix index b251e9e752f6b2..681e0e3533e5a3 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_repack.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_repack.nix @@ -4,13 +4,14 @@ , postgresql , postgresqlTestExtension , testers +, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "pg_repack"; version = "1.5.0"; - buildInputs = postgresql.buildInputs ++ [ postgresql ]; + buildInputs = postgresql.buildInputs; src = fetchFromGitHub { owner = "reorg"; @@ -19,12 +20,6 @@ stdenv.mkDerivation (finalAttrs: { sha256 = "sha256-do80phyMxwcRIkYyUt9z02z7byNQhK+pbSaCUmzG+4c="; }; - installPhase = '' - install -D bin/pg_repack -t $out/bin/ - install -D lib/pg_repack${postgresql.dlSuffix} -t $out/lib/ - install -D lib/{pg_repack--${finalAttrs.version}.sql,pg_repack.control} -t $out/share/postgresql/extension - ''; - passthru.tests = { version = testers.testVersion { package = finalAttrs.finalPackage; diff --git a/pkgs/servers/sql/postgresql/ext/pg_roaringbitmap.nix b/pkgs/servers/sql/postgresql/ext/pg_roaringbitmap.nix index 682275fbf15caf..7e7a29f47b16a9 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_roaringbitmap.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_roaringbitmap.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql, postgresqlTestHook }: +{ lib, stdenv, fetchFromGitHub, postgresql, postgresqlTestHook, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "pg_roaringbitmap"; version = "0.5.4"; @@ -11,16 +11,6 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-E6vqawnsRsAIajGDgJcTUWV1H8GFFboTjhmVfemUGbs="; }; - buildInputs = [ - postgresql - ]; - - installPhase = '' - install -D -t $out/lib roaringbitmap${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension roaringbitmap-*.sql - install -D -t $out/share/postgresql/extension roaringbitmap.control - ''; - meta = with lib; { description = "RoaringBitmap extension for PostgreSQL"; homepage = "https://github.com/ChenHuajun/pg_roaringbitmap"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_safeupdate.nix b/pkgs/servers/sql/postgresql/ext/pg_safeupdate.nix index 6637c98c95654c..728a0ea37a0d37 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_safeupdate.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_safeupdate.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: with { "12" = { @@ -23,12 +23,10 @@ with { }; }."${lib.versions.major postgresql.version}" or (throw "pg_safeupdate: version specification for pg ${postgresql.version} missing."); -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg-safeupdate"; inherit version; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "eradman"; repo = pname; @@ -36,10 +34,6 @@ stdenv.mkDerivation rec { inherit sha256; }; - installPhase = '' - install -D safeupdate${postgresql.dlSuffix} -t $out/lib - ''; - meta = with lib; { description = "Simple extension to PostgreSQL that requires criteria for UPDATE and DELETE"; homepage = "https://github.com/eradman/pg-safeupdate"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_similarity.nix b/pkgs/servers/sql/postgresql/ext/pg_similarity.nix index a0669331055b03..10f61e3f7f8982 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_similarity.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_similarity.nix @@ -1,9 +1,9 @@ -{ stdenv, lib, fetchFromGitHub, gcc, postgresql }: - -stdenv.mkDerivation { +{ stdenv, lib, fetchFromGitHub, gcc, postgresql, buildPostgresExtension }: +buildPostgresExtension { pname = "pg_similarity"; version = "1.0"; + src = fetchFromGitHub { owner = "eulerto"; repo = "pg_similarity"; @@ -11,15 +11,10 @@ stdenv.mkDerivation { sha256 = "1z4v4r2yccdr8kz3935fnk1bc5vj0qj0apscldyap4wxlyi89xim"; }; - buildInputs = [ postgresql gcc ]; + buildInputs = [ gcc ]; makeFlags = [ "USE_PGXS=1" ]; - installPhase = '' - install -D pg_similarity${postgresql.dlSuffix} -t $out/lib/ - install -D ./{pg_similarity--unpackaged--1.0.sql,pg_similarity--1.0.sql,pg_similarity.control} -t $out/share/postgresql/extension - ''; - meta = { description = "Extension to support similarity queries on PostgreSQL"; longDescription = '' diff --git a/pkgs/servers/sql/postgresql/ext/pg_squeeze.nix b/pkgs/servers/sql/postgresql/ext/pg_squeeze.nix index 6e09fe9a73188c..a9bc41f2774eec 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_squeeze.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_squeeze.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql, postgresqlTestExtension }: +{ lib, stdenv, fetchFromGitHub, postgresql, postgresqlTestExtension, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "pg_squeeze"; version = "1.6.2"; @@ -11,20 +11,6 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-YS13iIpQ4NJe0N6bRVa2RDxEMwEzBc2mjNYM5/Vqjn8="; }; - buildInputs = [ - postgresql - ]; - - installPhase = '' - runHook preInstall - - install -D -t $out/lib pg_squeeze${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension pg_squeeze-*.sql - install -D -t $out/share/postgresql/extension pg_squeeze.control - - runHook postInstall - ''; - passthru.tests.extension = postgresqlTestExtension { inherit (finalAttrs) finalPackage; postgresqlExtraSettings = '' diff --git a/pkgs/servers/sql/postgresql/ext/pg_topn.nix b/pkgs/servers/sql/postgresql/ext/pg_topn.nix index 2a11417c908312..e06bbf4728f5d9 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_topn.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_topn.nix @@ -1,11 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_topn"; version = "2.6.0"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "citusdata"; repo = "postgresql-topn"; @@ -13,14 +11,6 @@ stdenv.mkDerivation rec { sha256 = "sha256-kq3P+a9NWLKN/CsISGHfInbeL4ex4KIeDhTKyyN7FVE="; }; - installPhase = '' - mkdir -p $out/{lib,share/postgresql/extension} - - cp *${postgresql.dlSuffix} $out/lib - cp *.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; - meta = with lib; { description = "Efficient querying of 'top values' for PostgreSQL"; homepage = "https://github.com/citusdata/postgresql-topn"; diff --git a/pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix b/pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix index 80afe05db808ef..7469d9897a8dc7 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix @@ -2,14 +2,13 @@ , stdenv , fetchFromGitHub , postgresql +, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pg_uuidv7"; version = "1.5.0"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "fboulnois"; repo = "pg_uuidv7"; @@ -17,11 +16,6 @@ stdenv.mkDerivation rec { hash = "sha256-oVyRtjl3KsD3j96qvQb8bFLMhoWO81OudOL4wVXrjzI="; }; - installPhase = '' - install -D -t $out/lib pg_uuidv7${postgresql.dlSuffix} - install -D {sql/pg_uuidv7--${lib.versions.majorMinor version}.sql,pg_uuidv7.control} -t $out/share/postgresql/extension - ''; - meta = with lib; { description = "Tiny Postgres extension to create version 7 UUIDs"; homepage = "https://github.com/fboulnois/pg_uuidv7"; diff --git a/pkgs/servers/sql/postgresql/ext/pgaudit.nix b/pkgs/servers/sql/postgresql/ext/pgaudit.nix index f4c03d611f5037..2302ba193f4956 100644 --- a/pkgs/servers/sql/postgresql/ext/pgaudit.nix +++ b/pkgs/servers/sql/postgresql/ext/pgaudit.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchFromGitHub, libkrb5, openssl, postgresql }: +{ lib, stdenv, fetchFromGitHub, libkrb5, openssl, postgresql, buildPostgresExtension }: let source = { @@ -24,7 +24,7 @@ let }; }.${lib.versions.major postgresql.version} or (throw "Source for pgaudit is not available for ${postgresql.version}"); in -stdenv.mkDerivation { +buildPostgresExtension { pname = "pgaudit"; inherit (source) version; @@ -35,16 +35,10 @@ stdenv.mkDerivation { hash = source.hash; }; - buildInputs = [ libkrb5 openssl postgresql ]; + buildInputs = [ libkrb5 openssl ]; makeFlags = [ "USE_PGXS=1" ]; - installPhase = '' - install -D -t $out/lib pgaudit${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "Open Source PostgreSQL Audit Logging"; homepage = "https://github.com/pgaudit/pgaudit"; diff --git a/pkgs/servers/sql/postgresql/ext/pgjwt.nix b/pkgs/servers/sql/postgresql/ext/pgjwt.nix index a90502c35a4e8e..a22c767853f539 100644 --- a/pkgs/servers/sql/postgresql/ext/pgjwt.nix +++ b/pkgs/servers/sql/postgresql/ext/pgjwt.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql, unstableGitUpdater, nixosTests, postgresqlTestExtension }: +{ lib, stdenv, fetchFromGitHub, postgresql, unstableGitUpdater, nixosTests, postgresqlTestExtension, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "pgjwt"; version = "0-unstable-2023-03-02"; @@ -11,12 +11,6 @@ stdenv.mkDerivation (finalAttrs: { sha256 = "sha256-nDZEDf5+sFc1HDcG2eBNQj+kGcdAYRXJseKi9oww+JU="; }; - dontBuild = true; - installPhase = '' - mkdir -p $out/share/postgresql/extension - cp pg*sql *.control $out/share/postgresql/extension - ''; - passthru.updateScript = unstableGitUpdater { }; passthru.tests = { diff --git a/pkgs/servers/sql/postgresql/ext/pgmq.nix b/pkgs/servers/sql/postgresql/ext/pgmq.nix index 2cbf3caa433389..8a5319efb66b02 100644 --- a/pkgs/servers/sql/postgresql/ext/pgmq.nix +++ b/pkgs/servers/sql/postgresql/ext/pgmq.nix @@ -3,9 +3,10 @@ stdenv, fetchFromGitHub, postgresql, + buildPostgresqlExtension, }: -stdenv.mkDerivation rec { +buildPostgresqlExtension rec { pname = "pgmq"; version = "1.4.4"; @@ -20,17 +21,6 @@ stdenv.mkDerivation rec { dontConfigure = true; - buildInputs = [ postgresql ]; - - installPhase = '' - runHook preInstall - - install -D -t $out/share/postgresql/extension sql/*.sql - install -D -t $out/share/postgresql/extension *.control - - runHook postInstall - ''; - meta = { description = "Lightweight message queue like AWS SQS and RSMQ but on Postgres"; homepage = "https://tembo.io/pgmq"; diff --git a/pkgs/servers/sql/postgresql/ext/pgroonga.nix b/pkgs/servers/sql/postgresql/ext/pgroonga.nix index 0ba7fa093820c2..734892f4b24dde 100644 --- a/pkgs/servers/sql/postgresql/ext/pgroonga.nix +++ b/pkgs/servers/sql/postgresql/ext/pgroonga.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, groonga }: +{ lib, stdenv, fetchurl, pkg-config, postgresql, msgpack-c, groonga, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pgroonga"; version = "3.1.8"; @@ -10,23 +10,13 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ pkg-config ]; - buildInputs = [ postgresql msgpack-c groonga ]; + buildInputs = [ msgpack-c groonga ]; makeFlags = [ "HAVE_MSGPACK=1" "MSGPACK_PACKAGE_NAME=msgpack-c" ]; - installPhase = '' - install -D pgroonga${postgresql.dlSuffix} -t $out/lib/ - install -D pgroonga.control -t $out/share/postgresql/extension - install -D data/pgroonga-*.sql -t $out/share/postgresql/extension - - install -D pgroonga_database${postgresql.dlSuffix} -t $out/lib/ - install -D pgroonga_database.control -t $out/share/postgresql/extension - install -D data/pgroonga_database-*.sql -t $out/share/postgresql/extension - ''; - meta = with lib; { description = "PostgreSQL extension to use Groonga as the index"; longDescription = '' diff --git a/pkgs/servers/sql/postgresql/ext/pgrouting.nix b/pkgs/servers/sql/postgresql/ext/pgrouting.nix index d67a21755a0670..35a996bc562e5e 100644 --- a/pkgs/servers/sql/postgresql/ext/pgrouting.nix +++ b/pkgs/servers/sql/postgresql/ext/pgrouting.nix @@ -1,11 +1,11 @@ -{ lib, stdenv, fetchFromGitHub, postgresql, perl, cmake, boost }: +{ lib, stdenv, fetchFromGitHub, postgresql, perl, cmake, boost, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pgrouting"; version = "3.6.3"; nativeBuildInputs = [ cmake perl ]; - buildInputs = [ postgresql boost ]; + buildInputs = [ boost ]; src = fetchFromGitHub { owner = "pgRouting"; @@ -14,12 +14,6 @@ stdenv.mkDerivation rec { hash = "sha256-VCoapUM7Vh4W1DUE/gWQ9YIRLbw63XlOWsgajJW+XNU="; }; - installPhase = '' - install -D lib/*.so -t $out/lib - install -D sql/pgrouting--${version}.sql -t $out/share/postgresql/extension - install -D sql/common/pgrouting.control -t $out/share/postgresql/extension - ''; - meta = with lib; { description = "PostgreSQL/PostGIS extension that provides geospatial routing functionality"; homepage = "https://pgrouting.org/"; diff --git a/pkgs/servers/sql/postgresql/ext/pgsodium.nix b/pkgs/servers/sql/postgresql/ext/pgsodium.nix index 59ddfcd74c8c55..33c2358277e282 100644 --- a/pkgs/servers/sql/postgresql/ext/pgsodium.nix +++ b/pkgs/servers/sql/postgresql/ext/pgsodium.nix @@ -4,9 +4,10 @@ , libsodium , postgresql , postgresqlTestExtension +, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "pgsodium"; version = "3.1.9"; @@ -19,20 +20,11 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ libsodium - postgresql ]; - installPhase = '' - runHook preInstall - - install -D -t $out/lib pgsodium${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension sql/pgsodium-*.sql - install -D -t $out/share/postgresql/extension pgsodium.control - + postInstall = '' install -D -t $out/share/pgsodium/getkey_scripts getkey_scripts/* ln -s $out/share/pgsodium/getkey_scripts/pgsodium_getkey_urandom.sh $out/share/postgresql/extension/pgsodium_getkey - - runHook postInstall ''; passthru.tests.extension = postgresqlTestExtension { diff --git a/pkgs/servers/sql/postgresql/ext/pgsql-http.nix b/pkgs/servers/sql/postgresql/ext/pgsql-http.nix index bfe9052acf5873..975bd3dbf81872 100644 --- a/pkgs/servers/sql/postgresql/ext/pgsql-http.nix +++ b/pkgs/servers/sql/postgresql/ext/pgsql-http.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, curl, postgresql }: +{ lib, stdenv, fetchFromGitHub, curl, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pgsql-http"; version = "1.6.0"; @@ -11,13 +11,7 @@ stdenv.mkDerivation rec { hash = "sha256-CPHfx7vhWfxkXsoKTzyFuTt47BPMvzi/pi1leGcuD60="; }; - buildInputs = [ curl postgresql ]; - - installPhase = '' - install -D -t $out/lib *${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; + buildInputs = [ curl ]; meta = with lib; { description = "HTTP client for PostgreSQL, retrieve a web page from inside the database"; diff --git a/pkgs/servers/sql/postgresql/ext/pgtap.nix b/pkgs/servers/sql/postgresql/ext/pgtap.nix index 24ad1f610e8f43..f34e3f2859f406 100644 --- a/pkgs/servers/sql/postgresql/ext/pgtap.nix +++ b/pkgs/servers/sql/postgresql/ext/pgtap.nix @@ -1,5 +1,6 @@ { lib , stdenv +, buildPostgresExtension , fetchFromGitHub , perl , perlPackages @@ -8,7 +9,7 @@ , which }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "pgtap"; version = "1.3.3"; @@ -21,10 +22,6 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ postgresql perl perlPackages.TAPParserSourceHandlerpgTAP which ]; - installPhase = '' - install -D {sql/pgtap--${finalAttrs.version}.sql,pgtap.control} -t $out/share/postgresql/extension - ''; - passthru.tests.extension = stdenv.mkDerivation { name = "pgtap-test"; dontUnpack = true; diff --git a/pkgs/servers/sql/postgresql/ext/pgvector.nix b/pkgs/servers/sql/postgresql/ext/pgvector.nix index 619c5e7ab24d33..7794899009b378 100644 --- a/pkgs/servers/sql/postgresql/ext/pgvector.nix +++ b/pkgs/servers/sql/postgresql/ext/pgvector.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "pgvector"; version = "0.6.2"; @@ -11,14 +11,6 @@ stdenv.mkDerivation rec { hash = "sha256-r+TpFJg6WrMn0L2B7RpmSRvw3XxpHzMRtpFWDCzLvgs="; }; - buildInputs = [ postgresql ]; - - installPhase = '' - install -D -t $out/lib vector${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension sql/vector-*.sql - install -D -t $out/share/postgresql/extension vector.control - ''; - meta = with lib; { description = "Open-source vector similarity search for PostgreSQL"; homepage = "https://github.com/pgvector/pgvector"; diff --git a/pkgs/servers/sql/postgresql/ext/plpgsql_check.nix b/pkgs/servers/sql/postgresql/ext/plpgsql_check.nix index e03a3bf51fe55e..cbc3a98da20be1 100644 --- a/pkgs/servers/sql/postgresql/ext/plpgsql_check.nix +++ b/pkgs/servers/sql/postgresql/ext/plpgsql_check.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql, postgresqlTestExtension }: +{ lib, stdenv, fetchFromGitHub, postgresql, postgresqlTestExtension, buildPostgresExtension }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "plpgsql-check"; version = "2.7.5"; @@ -11,14 +11,6 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-CD/G/wX6o+mC6gowlpFe1DdJWyh3cB9wxSsW2GXrENE="; }; - buildInputs = [ postgresql ]; - - installPhase = '' - install -D -t $out/lib *${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - passthru.tests.extension = postgresqlTestExtension { inherit (finalAttrs) finalPackage; sql = "CREATE EXTENSION plpgsql_check;"; diff --git a/pkgs/servers/sql/postgresql/ext/plr.nix b/pkgs/servers/sql/postgresql/ext/plr.nix index 05d22c19a8b0ce..19c8c109bedc26 100644 --- a/pkgs/servers/sql/postgresql/ext/plr.nix +++ b/pkgs/servers/sql/postgresql/ext/plr.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, pkg-config, R, postgresql }: +{ lib, stdenv, fetchFromGitHub, pkg-config, R, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "plr"; version = "8.4.6"; @@ -12,15 +12,10 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ pkg-config ]; - buildInputs = [ R postgresql ]; + buildInputs = [ R ]; makeFlags = [ "USE_PGXS=1" ]; - installPhase = '' - install -D plr${postgresql.dlSuffix} -t $out/lib/ - install -D {plr--*.sql,plr.control} -t $out/share/postgresql/extension - ''; - meta = with lib; { description = "PL/R - R Procedural Language for PostgreSQL"; homepage = "https://github.com/postgres-plr/plr"; diff --git a/pkgs/servers/sql/postgresql/ext/plv8/default.nix b/pkgs/servers/sql/postgresql/ext/plv8/default.nix index e0dbc19e353fa2..d6d0e62b151c54 100644 --- a/pkgs/servers/sql/postgresql/ext/plv8/default.nix +++ b/pkgs/servers/sql/postgresql/ext/plv8/default.nix @@ -5,6 +5,7 @@ , perl , postgresql , jitSupport +, buildPostgresExtension # For test , runCommand , coreutils @@ -13,7 +14,7 @@ let libv8 = nodejs_20.libv8; -in stdenv.mkDerivation (finalAttrs: { +in buildPostgresExtension (finalAttrs: { pname = "plv8"; version = "3.2.2"; @@ -36,7 +37,6 @@ in stdenv.mkDerivation (finalAttrs: { buildInputs = [ libv8 - postgresql ]; buildFlags = [ "all" ]; @@ -48,11 +48,6 @@ in stdenv.mkDerivation (finalAttrs: { "V8_OUTDIR=${libv8}/lib" ]; - installFlags = [ - # PGXS only supports installing to postgresql prefix so we need to redirect this - "DESTDIR=${placeholder "out"}" - ]; - # No configure script. dontConfigure = true; @@ -60,14 +55,6 @@ in stdenv.mkDerivation (finalAttrs: { patchShebangs ./generate_upgrade.sh ''; - postInstall = '' - # Move the redirected to proper directory. - # There appear to be no references to the install directories - # so changing them does not cause issues. - mv "$out/nix/store"/*/* "$out" - rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix" - ''; - passthru = { tests = let diff --git a/pkgs/servers/sql/postgresql/ext/postgis.nix b/pkgs/servers/sql/postgresql/ext/postgis.nix index aa62c778a3fda5..04fd6ed0fef80d 100644 --- a/pkgs/servers/sql/postgresql/ext/postgis.nix +++ b/pkgs/servers/sql/postgresql/ext/postgis.nix @@ -21,12 +21,13 @@ nixosTests, jitSupport, llvm, + buildPostgresExtension, }: let gdal = gdalMinimal; in -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "postgis"; version = "3.5.0"; @@ -42,7 +43,6 @@ stdenv.mkDerivation rec { buildInputs = [ libxml2 - postgresql geos proj gdal @@ -68,20 +68,18 @@ stdenv.mkDerivation rec { # postgis config directory assumes /include /lib from the same root for json-c library env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib"; + setOutputFlags = false; preConfigure = '' sed -i 's@/usr/bin/file@${file}/bin/file@' configure - configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --docdir=$doc/share/doc/${pname} --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev} --disable-extension-upgrades-install" - - makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin docdir=$doc/share/doc/${pname}" ''; + + configureFlags = [ + "--with-gdalconfig=${gdal}/bin/gdal-config" + "--with-jsondir=${json_c.dev}" + "--disable-extension-upgrades-install" + ]; + postConfigure = '' - sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ; - s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g - " \ - "raster/loader/Makefile"; - sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g - " \ - "raster/scripts/python/Makefile"; mkdir -p $out/bin # postgis' build system assumes it is being installed to the same place as postgresql, and looks @@ -89,12 +87,13 @@ stdenv.mkDerivation rec { ln -s ${postgresql}/bin/postgres $out/bin/postgres ''; + makeFlags = [ + "PERL=${perl}/bin/perl" + ]; + doCheck = stdenv.hostPlatform.isLinux; preCheck = '' - substituteInPlace regress/run_test.pl --replace-fail "/share/contrib/postgis" "$out/share/postgresql/contrib/postgis" - substituteInPlace regress/Makefile --replace-fail 's,\$$libdir,$(REGRESS_INSTALLDIR)/lib,g' "s,\\$\$libdir,$PWD/regress/00-regress-install$out/lib,g" \ - --replace-fail '$(REGRESS_INSTALLDIR)/share/contrib/postgis/*.sql' "$PWD/regress/00-regress-install$out/share/postgresql/contrib/postgis/*.sql" substituteInPlace doc/postgis-out.xml --replace-fail "http://docbook.org/xml/5.0/dtd/docbook.dtd" "${docbook5}/xml/dtd/docbook/docbookx.dtd" # The test suite hardcodes it to use /tmp. export PGIS_REG_TMPDIR="$TMPDIR/pgis_reg" diff --git a/pkgs/servers/sql/postgresql/ext/repmgr.nix b/pkgs/servers/sql/postgresql/ext/repmgr.nix index 565f3fdaf60dca..08185982d33d9a 100644 --- a/pkgs/servers/sql/postgresql/ext/repmgr.nix +++ b/pkgs/servers/sql/postgresql/ext/repmgr.nix @@ -5,9 +5,10 @@ , flex , curl , json_c +, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "repmgr"; version = "5.4.1"; @@ -20,16 +21,7 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ flex ]; - buildInputs = postgresql.buildInputs ++ [ postgresql curl json_c ]; - - installPhase = '' - mkdir -p $out/{bin,lib,share/postgresql/extension} - - cp repmgr{,d} $out/bin - cp *${postgresql.dlSuffix} $out/lib - cp *.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - ''; + buildInputs = postgresql.buildInputs ++ [ curl json_c ]; meta = with lib; { homepage = "https://repmgr.org/"; diff --git a/pkgs/servers/sql/postgresql/ext/rum.nix b/pkgs/servers/sql/postgresql/ext/rum.nix index 629fddfcbb30f2..02474a99fbbc88 100644 --- a/pkgs/servers/sql/postgresql/ext/rum.nix +++ b/pkgs/servers/sql/postgresql/ext/rum.nix @@ -4,9 +4,10 @@ fetchFromGitHub, postgresql, postgresqlTestHook, + buildPostgresExtension, }: -stdenv.mkDerivation (finalAttrs: { +buildPostgresExtension (finalAttrs: { pname = "rum"; version = "1.3.14"; @@ -17,16 +18,8 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-VsfpxQqRBu9bIAP+TfMRXd+B3hSjuhU2NsutocNiCt8="; }; - buildInputs = [ postgresql ]; - makeFlags = [ "USE_PGXS=1" ]; - installPhase = '' - install -D -t $out/lib *${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.control - install -D -t $out/share/postgresql/extension *.sql - ''; - passthru.tests.extension = stdenv.mkDerivation { inherit (finalAttrs) version; pname = "rum-test"; diff --git a/pkgs/servers/sql/postgresql/ext/smlar.nix b/pkgs/servers/sql/postgresql/ext/smlar.nix index 12fdd79cc8f42b..f79793e2fa37de 100644 --- a/pkgs/servers/sql/postgresql/ext/smlar.nix +++ b/pkgs/servers/sql/postgresql/ext/smlar.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchgit, postgresql }: +{ lib, stdenv, fetchgit, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "smlar-unstable"; version = "2021-11-08"; @@ -10,16 +10,8 @@ stdenv.mkDerivation rec { hash = "sha256-AC6w7uYw0OW70pQpWbK1A3rkCnMvTJzTCAdFiY3rO7A="; }; - buildInputs = [ postgresql ]; - makeFlags = [ "USE_PGXS=1" ]; - installPhase = '' - install -D -t $out/lib *.so - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "Compute similary of any one-dimensional arrays"; homepage = "http://sigaev.ru/git/gitweb.cgi?p=smlar.git"; diff --git a/pkgs/servers/sql/postgresql/ext/system_stats.nix b/pkgs/servers/sql/postgresql/ext/system_stats.nix index c1700fc0380d66..ab437f86e0a02b 100644 --- a/pkgs/servers/sql/postgresql/ext/system_stats.nix +++ b/pkgs/servers/sql/postgresql/ext/system_stats.nix @@ -3,13 +3,12 @@ lib, stdenv, postgresql, + buildPostgresExtension, }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "system_stats"; version = "3.2"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "EnterpriseDB"; repo = "system_stats"; @@ -17,18 +16,6 @@ stdenv.mkDerivation rec { hash = "sha256-/xXnui0S0ZjRw7P8kMAgttHVv8T41aOhM3pM8P0OTig="; }; - installPhase = '' - runHook preInstall - - mkdir -p $out/{lib,share/postgresql/extension} - - cp *${postgresql.dlSuffix} $out/lib - cp *.sql $out/share/postgresql/extension - cp *.control $out/share/postgresql/extension - - runHook postInstall - ''; - meta = with lib; { description = "A Postgres extension for exposing system metrics such as CPU, memory and disk information"; homepage = "https://github.com/EnterpriseDB/system_stats"; diff --git a/pkgs/servers/sql/postgresql/ext/tds_fdw.nix b/pkgs/servers/sql/postgresql/ext/tds_fdw.nix index 4a192cda9aa338..50069b53758b9a 100644 --- a/pkgs/servers/sql/postgresql/ext/tds_fdw.nix +++ b/pkgs/servers/sql/postgresql/ext/tds_fdw.nix @@ -1,11 +1,11 @@ -{ lib, stdenv, fetchFromGitHub, postgresql, freetds, unstableGitUpdater }: +{ lib, stdenv, fetchFromGitHub, postgresql, freetds, unstableGitUpdater, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "tds_fdw"; # Move to stable version when it's released. version = "2.0.3-unstable-2024-02-10"; - buildInputs = [ postgresql freetds ]; + buildInputs = [ freetds ]; src = fetchFromGitHub { owner = "tds-fdw"; @@ -14,13 +14,6 @@ stdenv.mkDerivation rec { hash = "sha256-3J8wzk0YIxRPhALd5PgVW000hzQw3r4rTrnqg9uB/Bo="; }; - installPhase = '' - version="$(sed -En "s,^default_version *= *'([^']*)'.*,\1,p" tds_fdw.control)" - install -D tds_fdw${postgresql.dlSuffix} -t $out/lib - install -D sql/tds_fdw.sql "$out/share/postgresql/extension/tds_fdw--$version.sql" - install -D tds_fdw.control -t $out/share/postgresql/extension - ''; - passthru.updateScript = unstableGitUpdater { tagPrefix = "v"; }; diff --git a/pkgs/servers/sql/postgresql/ext/temporal_tables.nix b/pkgs/servers/sql/postgresql/ext/temporal_tables.nix index cb401829b2425d..e5bd03423b3ff4 100644 --- a/pkgs/servers/sql/postgresql/ext/temporal_tables.nix +++ b/pkgs/servers/sql/postgresql/ext/temporal_tables.nix @@ -1,11 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "temporal_tables"; version = "1.2.2"; - buildInputs = [ postgresql ]; - src = fetchFromGitHub { owner = "arkhipov"; repo = "temporal_tables"; @@ -13,12 +11,6 @@ stdenv.mkDerivation rec { sha256 = "sha256-7+DCSPAPhsokWDq/5IXNhd7jY6FfzxxUjlsg/VJeD3k="; }; - installPhase = '' - install -D -t $out/lib temporal_tables${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension *.sql - install -D -t $out/share/postgresql/extension *.control - ''; - meta = with lib; { description = "Temporal Tables PostgreSQL Extension"; homepage = "https://github.com/arkhipov/temporal_tables"; diff --git a/pkgs/servers/sql/postgresql/ext/timescaledb.nix b/pkgs/servers/sql/postgresql/ext/timescaledb.nix index bd2d2d3b74be64..f2224ad7590fcd 100644 --- a/pkgs/servers/sql/postgresql/ext/timescaledb.nix +++ b/pkgs/servers/sql/postgresql/ext/timescaledb.nix @@ -1,11 +1,11 @@ -{ lib, stdenv, fetchFromGitHub, cmake, postgresql, openssl, libkrb5, nixosTests, enableUnfree ? true }: +{ lib, stdenv, fetchFromGitHub, cmake, postgresql, openssl, libkrb5, nixosTests, enableUnfree ? true, buildPostgresExtension }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "timescaledb${lib.optionalString (!enableUnfree) "-apache"}"; version = "2.14.2"; nativeBuildInputs = [ cmake ]; - buildInputs = [ postgresql openssl libkrb5 ]; + buildInputs = [ openssl libkrb5 ]; src = fetchFromGitHub { owner = "timescale"; diff --git a/pkgs/servers/sql/postgresql/ext/tsearch_extras.nix b/pkgs/servers/sql/postgresql/ext/tsearch_extras.nix index b42095acd715c4..0841aa49035cb8 100644 --- a/pkgs/servers/sql/postgresql/ext/tsearch_extras.nix +++ b/pkgs/servers/sql/postgresql/ext/tsearch_extras.nix @@ -1,6 +1,6 @@ -{ lib, stdenv, fetchFromGitHub, postgresql }: +{ lib, stdenv, fetchFromGitHub, postgresql, buildPostgresExtension }: -stdenv.mkDerivation { +buildPostgresExtension { pname = "tsearch-extras"; version = "0.4"; @@ -11,13 +11,6 @@ stdenv.mkDerivation { sha256 = "18j0saqblg3jhrz38splk173xjwdf32c67ymm18m8n5y94h8d2ba"; }; - buildInputs = [ postgresql ]; - - installPhase = '' - install -D tsearch_extras${postgresql.dlSuffix} -t $out/lib/ - install -D ./{tsearch_extras--1.0.sql,tsearch_extras.control} -t $out/share/postgresql/extension - ''; - meta = with lib; { description = "Provides a few PostgreSQL functions for a lower-level data full text search"; homepage = "https://github.com/zulip/tsearch_extras/"; diff --git a/pkgs/servers/sql/postgresql/ext/tsja.nix b/pkgs/servers/sql/postgresql/ext/tsja.nix index f0b9238f59ef22..ed1aacca53d91b 100644 --- a/pkgs/servers/sql/postgresql/ext/tsja.nix +++ b/pkgs/servers/sql/postgresql/ext/tsja.nix @@ -2,7 +2,6 @@ , fetchzip , nixosTests , stdenv - , mecab , postgresql }: diff --git a/pkgs/servers/sql/postgresql/ext/wal2json.nix b/pkgs/servers/sql/postgresql/ext/wal2json.nix index 4a1c9b18b13b50..ce954030e45394 100644 --- a/pkgs/servers/sql/postgresql/ext/wal2json.nix +++ b/pkgs/servers/sql/postgresql/ext/wal2json.nix @@ -4,9 +4,10 @@ callPackage, fetchFromGitHub, postgresql, + buildPostgresExtension, }: -stdenv.mkDerivation rec { +buildPostgresExtension rec { pname = "wal2json"; version = "2.6"; @@ -17,15 +18,8 @@ stdenv.mkDerivation rec { sha256 = "sha256-+QoACPCKiFfuT2lJfSUmgfzC5MXf75KpSoc2PzPxKyM="; }; - buildInputs = [ postgresql ]; - makeFlags = [ "USE_PGXS=1" ]; - installPhase = '' - install -D -t $out/lib *${postgresql.dlSuffix} - install -D -t $out/share/postgresql/extension sql/*.sql - ''; - passthru.tests.wal2json = lib.recurseIntoAttrs ( callPackage ../../../../../nixos/tests/postgresql-wal2json.nix { inherit (stdenv) system; diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index 539a4d05019d87..02072e51233613 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -287,6 +287,7 @@ let ''; installPhase = "touch $out"; } // extraArgs); + buildPostgresExtension = newSuper.callPackage ./buildPostgresExtension.nix {}; }; newSelf = self // scope; newSuper = { callPackage = newScope (scope // this.pkgs); };