From b924334c41be96907f1fb6019a729227e4efd165 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 23 Sep 2024 22:00:29 +0200 Subject: [PATCH] postgresql: fix pgxs Makefile for darwin The darwin specific Makefile contains a reference to the postgres binary. Some extensions are able to set bindir to their own output correctly for installation and will then fail to find the postgres binaryin their own output during linking. PostGIS worked around this by faking a postgres binary in their own output, but we can do better by hardcoding the proper path in the Makefile when PostgreSQL is built. --- pkgs/servers/sql/postgresql/ext/postgis.nix | 11 ----------- pkgs/servers/sql/postgresql/generic.nix | 6 ++++++ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/pkgs/servers/sql/postgresql/ext/postgis.nix b/pkgs/servers/sql/postgresql/ext/postgis.nix index 673ddf4b9eac..1611fe05600e 100644 --- a/pkgs/servers/sql/postgresql/ext/postgis.nix +++ b/pkgs/servers/sql/postgresql/ext/postgis.nix @@ -89,14 +89,6 @@ buildPostgresqlExtension (finalAttrs: { "--disable-extension-upgrades-install" ]; - postConfigure = '' - mkdir -p $out/bin - - # postgis' build system assumes it is being installed to the same place as postgresql, and looks - # for the postgres binary relative to $PREFIX. We gently support this system using an illusion. - ln -s ${postgresql}/bin/postgres $out/bin/postgres - ''; - makeFlags = [ "PERL=${perl}/bin/perl" ]; @@ -111,9 +103,6 @@ buildPostgresqlExtension (finalAttrs: { # create aliases for all commands adding version information postInstall = '' - # Teardown the illusory postgres used for building; see postConfigure. - rm $out/bin/postgres - for prog in $out/bin/*; do # */ ln -s $prog $prog-${finalAttrs.version} done diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index e8cc44240835..01fa8e647f9a 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -284,6 +284,12 @@ let # Stop lib depending on the -dev output of llvm remove-references-to -t ${llvmPackages.llvm.dev} "$out/lib/llvmjit${dlSuffix}" + '' + lib.optionalString stdenv'.hostPlatform.isDarwin '' + # The darwin specific Makefile for PGXS contains a reference to the postgres + # binary. Some extensions (here: postgis), which are able to set bindir correctly + # to their own output for installation, will then fail to find "postgres" during linking. + substituteInPlace "$dev/lib/pgxs/src/Makefile.port" \ + --replace-fail '-bundle_loader $(bindir)/postgres' "-bundle_loader $out/bin/postgres" ''; postFixup = lib.optionalString stdenv'.hostPlatform.isGnu