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.
This commit is contained in:
Jonathan King
2026-05-11 17:01:23 +01:00
parent 3c40a2fc4b
commit 4c9cd46a43
+7 -1
View File
@@ -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;