diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix index 2effd687e8e4..82ae3d4ac21f 100644 --- a/pkgs/servers/sql/postgresql/generic.nix +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -247,9 +247,11 @@ let # flags will remove unused sections from all shared libraries and binaries - including # those paths. This avoids a lot of circular dependency problems with different outputs, # and allows splitting them cleanly. - env.CFLAGS = - "-fdata-sections -ffunction-sections" - + (if stdenv'.cc.isClang then " -flto" else " -fmerge-constants -Wl,--gc-sections"); + env = { + CFLAGS = + "-fdata-sections -ffunction-sections" + + (if stdenv'.cc.isClang then " -flto" else " -fmerge-constants -Wl,--gc-sections"); + } // lib.optionalAttrs pythonSupport { PYTHON = "${python3}/bin/python"; }; configureFlags = let @@ -378,10 +380,14 @@ let --replace-fail '-bundle_loader $(bindir)/postgres' "-bundle_loader $out/bin/postgres" ''; - postFixup = lib.optionalString stdenv'.hostPlatform.isGnu '' - # initdb needs access to "locale" command from glibc. - wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin - ''; + postFixup = + lib.optionalString stdenv'.hostPlatform.isGnu '' + # initdb needs access to "locale" command from glibc. + wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin + '' + + lib.optionalString pythonSupport '' + wrapProgram "$out/bin/postgres" --set PYTHONPATH "${python3}/${python3.sitePackages}" + ''; # Running tests as "install check" to work around SIP issue on macOS: # https://www.postgresql.org/message-id/flat/4D8E1BC5-BBCF-4B19-8226-359201EA8305%40gmail.com