From ed0efe5907389aab8540fe1204ec311aad465233 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 10 Sep 2025 16:07:21 +0200 Subject: [PATCH] pkgsStatic.libpq: fix build This has worked before - but only accidentally so. It worked once we enabled `structuredAttrs`, but there was a bug in the stdenv adapter for `pkgsStatic`, which made it ineffective when using `structuredAttrs`. With the bug fixed, libpq was broken again. This time, we fix it by entirely disabling the build of shared libraries in PG's Makefiles for the static case. No shared libraries - no problem. --- pkgs/servers/sql/postgresql/libpq.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkgs/servers/sql/postgresql/libpq.nix b/pkgs/servers/sql/postgresql/libpq.nix index c64bb58d7e2b..f71d254ae7b6 100644 --- a/pkgs/servers/sql/postgresql/libpq.nix +++ b/pkgs/servers/sql/postgresql/libpq.nix @@ -118,6 +118,14 @@ stdenv.mkDerivation (finalAttrs: { postPatch = '' cat ${./pg_config.env.mk} >> src/common/Makefile + '' + # Explicitly disable building the shared libs, because that would fail with pkgsStatic. + + lib.optionalString stdenv.hostPlatform.isStatic '' + substituteInPlace src/interfaces/libpq/Makefile \ + --replace-fail "all: all-lib libpq-refs-stamp" "all: all-lib" + substituteInPlace src/Makefile.shlib \ + --replace-fail "all-lib: all-shared-lib" "all-lib: all-static-lib" \ + --replace-fail "install-lib: install-lib-shared" "install-lib: install-lib-static" ''; installPhase = '' @@ -141,14 +149,7 @@ stdenv.mkDerivation (finalAttrs: { ''; # PostgreSQL always builds both shared and static libs, so we delete those we don't want. - postInstall = - if stdenv.hostPlatform.isStatic then - '' - rm -rfv $out/lib/*.so* - touch $out/empty - '' - else - "rm -rfv $dev/lib/*.a"; + postInstall = if stdenv.hostPlatform.isStatic then "touch $out/empty" else "rm -rfv $dev/lib/*.a"; doCheck = false;