From 4c9cd46a439c1669b1fac3d0f323a6bee576fa91 Mon Sep 17 00:00:00 2001 From: Jonathan King Date: Mon, 11 May 2026 16:57:18 +0100 Subject: [PATCH] libpq: support dontDisableStatic Bring libpq into line with `pkgs/servers/sql/postgresql/generic.nix`, which already lets consumers retain the static archives alongside the shared libraries by setting `dontDisableStatic = true`. libpq's `postInstall` previously deleted every `.a` from `$dev/lib` unconditionally on non-static builds; consumers that need both the shared library and a native-ELF static archive had no in-tree way to keep them. The default behaviour is preserved: when `dontDisableStatic` is unset or `false`, the `.a` files are still removed, and the resulting `postInstall` string is identical to the previous one, so the derivation hash for existing consumers does not change. --- pkgs/servers/sql/postgresql/libpq.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/sql/postgresql/libpq.nix b/pkgs/servers/sql/postgresql/libpq.nix index 393341f0c919..2170f5cb2782 100644 --- a/pkgs/servers/sql/postgresql/libpq.nix +++ b/pkgs/servers/sql/postgresql/libpq.nix @@ -163,7 +163,13 @@ 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 "touch $out/empty" else "rm -rfv $dev/lib/*.a"; + # Honour the `dontDisableStatic` convention (see `generic.nix`) so consumers can keep + # the static archives in `$dev/lib` alongside the shared libraries in `$out/lib`. + postInstall = + if stdenv.hostPlatform.isStatic then + "touch $out/empty" + else + lib.optionalString (!(finalAttrs.dontDisableStatic or false)) "rm -rfv $dev/lib/*.a"; doCheck = false;