From 97cd23d8ec68f0f55d4f3037ce82565ff045303b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 17:58:04 +0200 Subject: [PATCH 01/15] feat(postgresql): move dynamic modules to default output Backport https://github.com/NixOS/nixpkgs/commit/5547322a0c01dd30a7e0111adc1f02bafbbd6ebc --- nix/cargo-pgrx/buildPgrxExtension.nix | 1 - nix/ext/tests/wrappers.nix | 7 --- nix/postgresql/generic.nix | 45 +++---------------- .../patches/paths-for-split-outputs.patch | 11 +++++ .../specify_pkglibdir_at_runtime.patch | 28 ------------ 5 files changed, 17 insertions(+), 75 deletions(-) delete mode 100644 nix/postgresql/patches/specify_pkglibdir_at_runtime.patch diff --git a/nix/cargo-pgrx/buildPgrxExtension.nix b/nix/cargo-pgrx/buildPgrxExtension.nix index adfee55ec..16e47ced8 100644 --- a/nix/cargo-pgrx/buildPgrxExtension.nix +++ b/nix/cargo-pgrx/buildPgrxExtension.nix @@ -160,7 +160,6 @@ let cargo-pgrx pgrx stop all mv $out/${postgresql}/* $out - mv $out/${postgresql.lib}/* $out rm -rf $out/nix ${maybeLeaveBuildAndTestSubdir} diff --git a/nix/ext/tests/wrappers.nix b/nix/ext/tests/wrappers.nix index 54cc63944..ceae1b647 100644 --- a/nix/ext/tests/wrappers.nix +++ b/nix/ext/tests/wrappers.nix @@ -13,7 +13,6 @@ let name = "postgresql-${majorVersion}-${pname}"; paths = [ postgresql - postgresql.lib (installedExtension majorVersion) ]; passthru = { @@ -21,17 +20,11 @@ let lib = pkg; withPackages = _: pkg; }; - nativeBuildInputs = [ pkgs.makeWrapper ]; pathsToLink = [ "/" "/bin" "/lib" ]; - postBuild = '' - wrapProgram $out/bin/postgres --set NIX_PGLIBDIR $out/lib - wrapProgram $out/bin/pg_ctl --set NIX_PGLIBDIR $out/lib - wrapProgram $out/bin/pg_upgrade --set NIX_PGLIBDIR $out/lib - ''; }; in pkg; diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 7cdf79ea5..7fa1b2ee1 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -185,7 +185,6 @@ let ) ./patches/less-is-more.patch ./patches/paths-for-split-outputs.patch - ./patches/specify_pkglibdir_at_runtime.patch ./patches/paths-with-postgresql-suffix.patch (replaceVars ./patches/locale-binary-path.patch { @@ -216,28 +215,18 @@ let installTargets = [ "install-world-bin" ]; - postPatch = - '' - # Hardcode the path to pgxs so pg_config returns the path in $out - substituteInPlace "src/common/config_info.c" --subst-var out - '' - + lib.optionalString jitSupport '' - # Force lookup of jit stuff in $out instead of $lib - substituteInPlace src/backend/jit/jit.c --replace pkglib_path \"$out/lib\" - substituteInPlace src/backend/jit/llvm/llvmjit.c --replace pkglib_path \"$out/lib\" - substituteInPlace src/backend/jit/llvm/llvmjit_inline.cpp --replace pkglib_path \"$out/lib\" - ''; + postPatch = '' + substituteInPlace "src/Makefile.global.in" --subst-var out + # Hardcode the path to pgxs so pg_config returns the path in $out + substituteInPlace "src/common/config_info.c" --subst-var out + ''; postInstall = '' - moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it moveToOutput "lib/libpgcommon*.a" "$out" moveToOutput "lib/libpgport*.a" "$out" moveToOutput "lib/libecpg*" "$out" - # Prevent a retained dependency on gcc-wrapper. - substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/ld ld - if [ -z "''${dontDisableStatic:-}" ]; then # Remove static libraries in case dynamic are available. for i in $out/lib/*.a $lib/lib/*.a; do @@ -250,11 +239,6 @@ let fi '' + lib.optionalString jitSupport '' - # Move the bitcode and libllvmjit.so library out of $lib; otherwise, every client that - # depends on libpq.so will also have libLLVM.so in its closure too, bloating it - moveToOutput "lib/bitcode" "$out" - moveToOutput "lib/llvmjit*" "$out" - # In the case of JIT support, prevent a retained dependency on clang-wrapper substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/clang clang nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f) @@ -318,7 +302,7 @@ let import ./ext newSelf newSuper; withPackages = postgresqlWithPackages { - inherit makeWrapper buildEnv; + inherit buildEnv; postgresql = this; } this.pkgs; @@ -382,7 +366,6 @@ let postgresqlWithPackages = { postgresql, - makeWrapper, buildEnv, }: pkgs: f: @@ -390,29 +373,13 @@ let name = "postgresql-and-plugins-${postgresql.version}"; paths = f pkgs ++ [ postgresql - postgresql.lib #TODO RM postgresql.man # in case user installs this into environment ]; - nativeBuildInputs = [ makeWrapper ]; - # We include /bin to ensure the $out/bin directory is created, which is - # needed because we'll be removing the files from that directory in postBuild - # below. See #22653 pathsToLink = [ "/" - "/bin" ]; - # Note: the duplication of executables is about 4MB size. - # So a nicer solution was patching postgresql to allow setting the - # libdir explicitly. - postBuild = '' - mkdir -p $out/bin - rm $out/bin/{pg_config,postgres,pg_ctl} - cp --target-directory=$out/bin ${postgresql}/bin/{postgres,pg_config,pg_ctl} - wrapProgram $out/bin/postgres --set NIX_PGLIBDIR $out/lib - ''; - passthru.version = postgresql.version; passthru.psqlSchema = postgresql.psqlSchema; }; diff --git a/nix/postgresql/patches/paths-for-split-outputs.patch b/nix/postgresql/patches/paths-for-split-outputs.patch index 2134f7e81..fca7aa10f 100644 --- a/nix/postgresql/patches/paths-for-split-outputs.patch +++ b/nix/postgresql/patches/paths-for-split-outputs.patch @@ -9,3 +9,14 @@ strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path)); cleanup_path(path); configdata[i].setting = pstrdup(path); +--- a/src/Makefile.global.in ++++ b/src/Makefile.global.in +@@ -116,7 +116,7 @@ endif + + libdir := @libdir@ + +-pkglibdir = $(libdir) ++pkglibdir = @out@/lib + ifeq "$(findstring pgsql, $(pkglibdir))" "" + ifeq "$(findstring postgres, $(pkglibdir))" "" + override pkglibdir := $(pkglibdir)/postgresql diff --git a/nix/postgresql/patches/specify_pkglibdir_at_runtime.patch b/nix/postgresql/patches/specify_pkglibdir_at_runtime.patch deleted file mode 100644 index b94fc9efc..000000000 --- a/nix/postgresql/patches/specify_pkglibdir_at_runtime.patch +++ /dev/null @@ -1,28 +0,0 @@ ---- a/src/port/path.c -+++ b/src/port/path.c -@@ -714,7 +714,11 @@ - void - get_lib_path(const char *my_exec_path, char *ret_path) - { -- make_relative_path(ret_path, LIBDIR, PGBINDIR, my_exec_path); -+ char const * const nix_pglibdir = getenv("NIX_PGLIBDIR"); -+ if(nix_pglibdir == NULL) -+ make_relative_path(ret_path, LIBDIR, PGBINDIR, my_exec_path); -+ else -+ make_relative_path(ret_path, nix_pglibdir, PGBINDIR, my_exec_path); - } - - /* -@@ -723,7 +727,11 @@ - void - get_pkglib_path(const char *my_exec_path, char *ret_path) - { -- make_relative_path(ret_path, PKGLIBDIR, PGBINDIR, my_exec_path); -+ char const * const nix_pglibdir = getenv("NIX_PGLIBDIR"); -+ if(nix_pglibdir == NULL) -+ make_relative_path(ret_path, PKGLIBDIR, PGBINDIR, my_exec_path); -+ else -+ make_relative_path(ret_path, nix_pglibdir, PGBINDIR, my_exec_path); - } - - /* From 472804b7557f1b9fa41d488def396a06c470ece4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 21:40:22 +0200 Subject: [PATCH 02/15] feat(postgresql): move libecpq to lib output Backport https://github.com/NixOS/nixpkgs/commit/77977286d80c9bfb77cbf80989d41c59d66dccf8 --- nix/postgresql/generic.nix | 63 ++++++++++++++----- .../patches/export-dynamic-darwin-15-.patch | 13 ++++ 2 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 nix/postgresql/patches/export-dynamic-darwin-15-.patch diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 7fa1b2ee1..7939b6c85 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -57,6 +57,7 @@ let nukeReferences, patchelf, llvmPackages, + overrideCC, # PL/Python pythonSupport ? false, @@ -82,7 +83,16 @@ let pname = "postgresql"; - stdenv' = if jitSupport then llvmPackages.stdenv else stdenv; + stdenv' = + if jitSupport then + overrideCC llvmPackages.stdenv ( + llvmPackages.stdenv.cc.override { + # LLVM bintools are not used by default, but are needed to make -flto work below. + bintools = llvmPackages.bintools; + } + ) + else + stdenv; in stdenv'.mkDerivation (finalAttrs: { inherit version; @@ -100,20 +110,31 @@ let inherit hash; }; + __structuredAttrs = true; + hardeningEnable = lib.optionals (!stdenv'.cc.isClang) [ "pie" ]; outputs = [ "out" "lib" + "doc" + "man" ]; setOutputFlags = false; # $out retains configureFlags :-/ + outputChecks.lib = { + disallowedReferences = [ + "out" + "doc" + "man" + ]; + }; buildInputs = [ zlib readline openssl - (libxml2.override { python = python3; }) + (libxml2.override { enableHttp = true; }) icu ] ++ lib.optionals (olderThan "13") [ libxcrypt ] @@ -150,11 +171,20 @@ let separateDebugInfo = true; - buildFlags = [ "world-bin" ]; - - # Makes cross-compiling work when xml2-config can't be executed on the host. - # Fixed upstream in https://github.com/postgres/postgres/commit/0bc8cebdb889368abdf224aeac8bc197fe4c9ae6 - env.NIX_CFLAGS_COMPILE = lib.optionalString (olderThan "13") "-I${libxml2.dev}/include/libxml2"; + buildFlags = [ "world" ]; + + # libpgcommon.a and libpgport.a contain all paths returned by pg_config and are linked + # into all binaries. However, almost no binaries actually use those paths. The following + # 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") + + lib.optionalString (stdenv'.isDarwin && jitSupport) " -fuse-ld=lld" + # Makes cross-compiling work when xml2-config can't be executed on the host. + # Fixed upstream in https://github.com/postgres/postgres/commit/0bc8cebdb889368abdf224aeac8bc197fe4c9ae6 + + lib.optionalString (olderThan "13") " -I${libxml2.dev}/include/libxml2"; configureFlags = [ @@ -173,7 +203,10 @@ let ++ lib.optionals gssSupport [ "--with-gssapi" ] ++ lib.optionals pythonSupport [ "--with-python" ] ++ lib.optionals jitSupport [ "--with-llvm" ] - ++ lib.optionals stdenv'.isLinux [ "--with-pam" ]; + ++ lib.optionals stdenv'.isLinux [ "--with-pam" ] + # This could be removed once the upstream issue is resolved: + # https://postgr.es/m/flat/427c7c25-e8e1-4fc5-a1fb-01ceff185e5b%40technowledgy.de + ++ lib.optionals (stdenv'.isDarwin && atLeast "16") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ]; patches = [ @@ -211,9 +244,12 @@ let ) ++ lib.optionals stdenv'.isLinux [ (if atLeast "13" then ./patches/socketdir-in-run-13+.patch else ./patches/socketdir-in-run.patch) + ] + ++ lib.optionals (stdenv'.isDarwin && olderThan "16") [ + ./patches/export-dynamic-darwin-15-.patch ]; - installTargets = [ "install-world-bin" ]; + installTargets = [ "install-world" ]; postPatch = '' substituteInPlace "src/Makefile.global.in" --subst-var out @@ -225,7 +261,9 @@ let '' moveToOutput "lib/libpgcommon*.a" "$out" moveToOutput "lib/libpgport*.a" "$out" - moveToOutput "lib/libecpg*" "$out" + + # Prevent a retained dependency on gcc-wrapper. + substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/ld ld if [ -z "''${dontDisableStatic:-}" ]; then # Remove static libraries in case dynamic are available. @@ -356,10 +394,7 @@ let # resulting LLVM IR isn't platform-independent this doesn't give you much. # In fact, I tried to test the result in a VM-test, but as soon as JIT was used to optimize # a query, postgres would coredump with `Illegal instruction`. - broken = - (jitSupport && stdenv.hostPlatform != stdenv.buildPlatform) - # Allmost all tests fail FATAL errors for v12 and v13 - || (jitSupport && stdenv.hostPlatform.isMusl && olderThan "14"); + broken = jitSupport && !stdenv.hostPlatform.canExecute stdenv.buildPlatform; }; }); diff --git a/nix/postgresql/patches/export-dynamic-darwin-15-.patch b/nix/postgresql/patches/export-dynamic-darwin-15-.patch new file mode 100644 index 000000000..fa0f4be4d --- /dev/null +++ b/nix/postgresql/patches/export-dynamic-darwin-15-.patch @@ -0,0 +1,13 @@ +See https://postgr.es/m/eb249761-56e2-4e42-a2c5-b9ae18c1ca1f%40technowledgy.de +--- +--- a/src/makefiles/Makefile.darwin ++++ b/src/makefiles/Makefile.darwin +@@ -5,6 +5,8 @@ DLSUFFIX = .so + # env var name to use in place of LD_LIBRARY_PATH + ld_library_path_var = DYLD_LIBRARY_PATH + ++export_dynamic = -Wl,-export_dynamic ++ + ifdef PGXS + BE_DLLLIBS = -bundle_loader $(bindir)/postgres + else From dd06610c85a7b9fdb3782bc4f0295396cf08f2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 22:22:08 +0200 Subject: [PATCH 03/15] feat(postgresql): split dev output Backport https://github.com/NixOS/nixpkgs/commit/435f51c37faf74375134dfbd7c5a4560da2a9ea7 --- nix/postgresql/generic.nix | 87 ++++++++++++++----- .../patches/empty-pg-config-view-15+.patch | 54 ++++++++++++ .../patches/empty-pg-config-view.patch | 50 +++++++++++ .../patches/paths-for-split-outputs.patch | 2 +- 4 files changed, 168 insertions(+), 25 deletions(-) create mode 100644 nix/postgresql/patches/empty-pg-config-view-15+.patch create mode 100644 nix/postgresql/patches/empty-pg-config-view.patch diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 7939b6c85..bd74b1dbd 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -25,6 +25,7 @@ let replaceVars, darwin, linux-pam, + removeReferencesTo, #orioledb specific perl, bison, @@ -116,17 +117,42 @@ let outputs = [ "out" - "lib" + "dev" "doc" + "lib" "man" ]; - setOutputFlags = false; # $out retains configureFlags :-/ + outputChecks.out = { + disallowedReferences = [ + "dev" + "doc" + "man" + ]; + disallowedRequisites = + [ + stdenv'.cc + ] + ++ (map lib.getDev (builtins.filter (drv: drv ? "dev") finalAttrs.buildInputs)) + ++ lib.optionals jitSupport [ + llvmPackages.llvm.out + ]; + }; + outputChecks.lib = { disallowedReferences = [ "out" + "dev" "doc" "man" ]; + disallowedRequisites = + [ + stdenv'.cc + ] + ++ (map lib.getDev (builtins.filter (drv: drv ? "dev") finalAttrs.buildInputs)) + ++ lib.optionals jitSupport [ + llvmPackages.llvm.out + ]; }; buildInputs = @@ -160,6 +186,7 @@ let [ makeWrapper pkg-config + removeReferencesTo ] ++ lib.optionals jitSupport [ llvmPackages.llvm.dev @@ -192,7 +219,6 @@ let "--with-libxml" "--with-icu" "--sysconfdir=/etc" - "--libdir=$(lib)/lib" "--with-system-tzdata=${tzdata}/share/zoneinfo" "--enable-debug" (lib.optionalString systemdSupport' "--with-systemd") @@ -216,6 +242,12 @@ let else ./patches/relative-to-symlinks.patch ) + ( + if atLeast "15" then + ./patches/empty-pg-config-view-15+.patch + else + ./patches/empty-pg-config-view.patch + ) ./patches/less-is-more.patch ./patches/paths-for-split-outputs.patch ./patches/paths-with-postgresql-suffix.patch @@ -253,21 +285,38 @@ let postPatch = '' substituteInPlace "src/Makefile.global.in" --subst-var out - # Hardcode the path to pgxs so pg_config returns the path in $out - substituteInPlace "src/common/config_info.c" --subst-var out + # Hardcode the path to pgxs so pg_config returns the path in $dev + substituteInPlace "src/common/config_info.c" --subst-var dev ''; postInstall = '' - moveToOutput "lib/libpgcommon*.a" "$out" - moveToOutput "lib/libpgport*.a" "$out" - - # Prevent a retained dependency on gcc-wrapper. - substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/ld ld + moveToOutput "bin/ecpg" "$dev" + moveToOutput "lib/pgxs" "$dev" + + # Pretend pg_config is located in $out/bin to return correct paths, but + # actually have it in -dev to avoid pulling in all other outputs. + moveToOutput "bin/pg_config" "$dev" + # To prevent a "pg_config: could not find own program executable" error, we fake + # pg_config in the default output. + cat << EOF > "$out/bin/pg_config" && chmod +x "$out/bin/pg_config" + #!${stdenv'.shell} + echo The real pg_config can be found in the -dev output. + exit 1 + EOF + wrapProgram "$dev/bin/pg_config" --argv0 "$out/bin/pg_config" + + # postgres exposes external symbols get_pkginclude_path and similar. Those + # can't be stripped away by --gc-sections/LTO, because they could theoretically + # be used by dynamically loaded modules / extensions. To avoid circular dependencies, + # references to -dev, -doc and -man are removed here. References to -lib must be kept, + # because there is a realistic use-case for extensions to locate the /lib directory to + # load other shared modules. + remove-references-to -t "$dev" -t "$doc" -t "$man" "$out/bin/postgres" if [ -z "''${dontDisableStatic:-}" ]; then # Remove static libraries in case dynamic are available. - for i in $out/lib/*.a $lib/lib/*.a; do + for i in $lib/lib/*.a; do name="$(basename "$i")" ext="${stdenv'.hostPlatform.extensions.sharedLibrary}" if [ -e "$lib/lib/''${name%.a}$ext" ] || [ -e "''${i%.a}$ext" ]; then @@ -275,22 +324,14 @@ let fi done fi + # The remaining static libraries are libpgcommon.a, libpgport.a and related. + # Those are only used when building e.g. extensions, so go to $dev. + moveToOutput "lib/*.a" "$dev" '' + lib.optionalString jitSupport '' # In the case of JIT support, prevent a retained dependency on clang-wrapper - substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/clang clang nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f) - # Stop out depending on the default output of llvm - substituteInPlace $out/lib/pgxs/src/Makefile.global \ - --replace ${llvmPackages.llvm.out}/bin "" \ - --replace '$(LLVM_BINPATH)/' "" - - # Stop out depending on the -dev output of llvm - substituteInPlace $out/lib/pgxs/src/Makefile.global \ - --replace ${llvmPackages.llvm.dev}/bin/llvm-config llvm-config \ - --replace -I${llvmPackages.llvm.dev}/include "" - ${lib.optionalString (!stdenv'.isDarwin) '' # Stop lib depending on the -dev output of llvm rpath=$(patchelf --print-rpath $out/lib/llvmjit.so) @@ -309,8 +350,6 @@ let # autodetection doesn't seem to able to find this, but it's there. checkTarget = "check"; - disallowedReferences = [ stdenv'.cc ]; - passthru = let this = self.callPackage generic args; diff --git a/nix/postgresql/patches/empty-pg-config-view-15+.patch b/nix/postgresql/patches/empty-pg-config-view-15+.patch new file mode 100644 index 000000000..c83e6964c --- /dev/null +++ b/nix/postgresql/patches/empty-pg-config-view-15+.patch @@ -0,0 +1,54 @@ +Empty the pg_config system information view. This view keeps references to +several -dev outputs, which we want to avoid to keep closure size down. + +The alternative to this patch would be to nuke references across the board, +but this will also affect the output of the pg_config utility. By emptying +the view only, we keep the pg_config binary intact. It resides in the -dev +output, so it's fine to have all those references there. + +--- +--- a/src/backend/utils/misc/pg_config.c ++++ b/src/backend/utils/misc/pg_config.c +@@ -32,20 +32,5 @@ pg_config(PG_FUNCTION_ARGS) + /* initialize our tuplestore */ + InitMaterializedSRF(fcinfo, 0); + +- configdata = get_configdata(my_exec_path, &configdata_len); +- for (i = 0; i < configdata_len; i++) +- { +- Datum values[2]; +- bool nulls[2]; +- +- memset(values, 0, sizeof(values)); +- memset(nulls, 0, sizeof(nulls)); +- +- values[0] = CStringGetTextDatum(configdata[i].name); +- values[1] = CStringGetTextDatum(configdata[i].setting); +- +- tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls); +- } +- + return (Datum) 0; + } +--- a/src/test/regress/expected/sysviews.out ++++ b/src/test/regress/expected/sysviews.out +@@ -29,7 +29,7 @@ select name, ident, parent, level, total_bytes >= free_bytes + (1 row) + + -- At introduction, pg_config had 23 entries; it may grow +-select count(*) > 20 as ok from pg_config; ++select count(*) = 0 as ok from pg_config; + ok + ---- + t +--- a/src/test/regress/sql/sysviews.sql ++++ b/src/test/regress/sql/sysviews.sql +@@ -18,7 +18,7 @@ select name, ident, parent, level, total_bytes >= free_bytes + from pg_backend_memory_contexts where level = 0; + + -- At introduction, pg_config had 23 entries; it may grow +-select count(*) > 20 as ok from pg_config; ++select count(*) = 0 as ok from pg_config; + + -- We expect no cursors in this test; see also portals.sql + select count(*) = 0 as ok from pg_cursors; diff --git a/nix/postgresql/patches/empty-pg-config-view.patch b/nix/postgresql/patches/empty-pg-config-view.patch new file mode 100644 index 000000000..98e4b8151 --- /dev/null +++ b/nix/postgresql/patches/empty-pg-config-view.patch @@ -0,0 +1,50 @@ +Empty the pg_config system information view. This view keeps references to +several -dev outputs, which we want to avoid to keep closure size down. + +The alternative to this patch would be to nuke references across the board, +but this will also affect the output of the pg_config utility. By emptying +the view only, we keep the pg_config binary intact. It resides in the -dev +output, so it's fine to have all those references there. + +--- +--- a/src/backend/utils/misc/pg_config.c ++++ b/src/backend/utils/misc/pg_config.c +@@ -69,16 +69,6 @@ pg_config(PG_FUNCTION_ARGS) + /* initialize our tuplestore */ + tupstore = tuplestore_begin_heap(true, false, work_mem); + +- configdata = get_configdata(my_exec_path, &configdata_len); +- for (i = 0; i < configdata_len; i++) +- { +- values[0] = configdata[i].name; +- values[1] = configdata[i].setting; +- +- tuple = BuildTupleFromCStrings(attinmeta, values); +- tuplestore_puttuple(tupstore, tuple); +- } +- + /* + * no longer need the tuple descriptor reference created by + * TupleDescGetAttInMetadata() +--- a/src/test/regress/expected/sysviews.out ++++ b/src/test/regress/expected/sysviews.out +@@ -20,7 +20,7 @@ select count(*) >= 0 as ok from pg_available_extensions; + (1 row) + + -- At introduction, pg_config had 23 entries; it may grow +-select count(*) > 20 as ok from pg_config; ++select count(*) = 0 as ok from pg_config; + ok + ---- + t +--- a/src/test/regress/sql/sysviews.sql ++++ b/src/test/regress/sql/sysviews.sql +@@ -13,7 +13,7 @@ select count(*) >= 0 as ok from pg_available_extension_versions; + select count(*) >= 0 as ok from pg_available_extensions; + + -- At introduction, pg_config had 23 entries; it may grow +-select count(*) > 20 as ok from pg_config; ++select count(*) = 0 as ok from pg_config; + + -- We expect no cursors in this test; see also portals.sql + select count(*) = 0 as ok from pg_cursors; diff --git a/nix/postgresql/patches/paths-for-split-outputs.patch b/nix/postgresql/patches/paths-for-split-outputs.patch index fca7aa10f..46164bba2 100644 --- a/nix/postgresql/patches/paths-for-split-outputs.patch +++ b/nix/postgresql/patches/paths-for-split-outputs.patch @@ -4,7 +4,7 @@ i++; configdata[i].name = pstrdup("PGXS"); -+ strlcpy(path, "@out@/lib", sizeof(path)); ++ strlcpy(path, "@dev@/lib", sizeof(path)); - get_pkglib_path(my_exec_path, path); strlcat(path, "/pgxs/src/makefiles/pgxs.mk", sizeof(path)); cleanup_path(path); From d8ad1b09e4d1825822dfa2e06a9ff2b01e1d1c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 22:35:57 +0200 Subject: [PATCH 04/15] feat(postgresql): remove references to llvm-dev on darwin as well Backport https://github.com/NixOS/nixpkgs/commit/94d432ce88b6dff272a17b4ed15dbefca14097fc --- nix/postgresql/generic.nix | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index bd74b1dbd..f6890ad14 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -56,7 +56,6 @@ let # JIT jitSupport, nukeReferences, - patchelf, llvmPackages, overrideCC, @@ -74,6 +73,8 @@ let lz4Enabled = atLeast "14"; zstdEnabled = atLeast "15"; + dlSuffix = if olderThan "16" then ".so" else stdenv.hostPlatform.extensions.sharedLibrary; + systemdSupport' = if enableSystemd == null then systemdSupport @@ -137,7 +138,6 @@ let llvmPackages.llvm.out ]; }; - outputChecks.lib = { disallowedReferences = [ "out" @@ -191,7 +191,6 @@ let ++ lib.optionals jitSupport [ llvmPackages.llvm.dev nukeReferences - patchelf ]; enableParallelBuilding = true; @@ -332,13 +331,8 @@ let # In the case of JIT support, prevent a retained dependency on clang-wrapper nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f) - ${lib.optionalString (!stdenv'.isDarwin) '' - # Stop lib depending on the -dev output of llvm - rpath=$(patchelf --print-rpath $out/lib/llvmjit.so) - nuke-refs -e $out $out/lib/llvmjit.so - # Restore the correct rpath - patchelf $out/lib/llvmjit.so --set-rpath "$rpath" - ''} + # Stop lib depending on the -dev output of llvm + remove-references-to -t ${llvmPackages.llvm.dev} "$out/lib/llvmjit${dlSuffix}" ''; postFixup = lib.optionalString (!stdenv'.isDarwin && stdenv'.hostPlatform.libc == "glibc") '' @@ -356,13 +350,13 @@ let jitToggle = this.override { jitSupport = !jitSupport; }; in { + inherit dlSuffix; + psqlSchema = lib.versions.major version; withJIT = if jitSupport then this else jitToggle; withoutJIT = if jitSupport then jitToggle else this; - dlSuffix = if olderThan "16" then ".so" else stdenv.hostPlatform.extensions.sharedLibrary; - pkgs = let scope = { From 79d408a2c21d075c8de45dd6c67c145bccd07fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 22:40:36 +0200 Subject: [PATCH 05/15] feat(postgresql): refactor removal of references in bitcode files Backport https://github.com/NixOS/nixpkgs/commit/dfde86f73857f575ae79785c1da9496599b38b2c --- nix/postgresql/generic.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index f6890ad14..4884fbb81 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -328,8 +328,8 @@ let moveToOutput "lib/*.a" "$dev" '' + lib.optionalString jitSupport '' - # In the case of JIT support, prevent a retained dependency on clang-wrapper - nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f) + # In the case of JIT support, prevent useless dependencies on header files + find "$out/lib" -iname '*.bc' -type f -exec nuke-refs '{}' + # Stop lib depending on the -dev output of llvm remove-references-to -t ${llvmPackages.llvm.dev} "$out/lib/llvmjit${dlSuffix}" From 8c1949b12d50d79e1bcdb2476a5cbaf12d1de2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 22:44:42 +0200 Subject: [PATCH 06/15] feat(postgresql): refactor to simplify condition Backport https://github.com/NixOS/nixpkgs/commit/73cb40366df17b3224970ae80e64527687bd5023 --- nix/postgresql/generic.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 4884fbb81..fd12f422f 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -335,7 +335,7 @@ let remove-references-to -t ${llvmPackages.llvm.dev} "$out/lib/llvmjit${dlSuffix}" ''; - postFixup = lib.optionalString (!stdenv'.isDarwin && stdenv'.hostPlatform.libc == "glibc") '' + postFixup = lib.optionalString stdenv'.hostPlatform.isGnu '' # initdb needs access to "locale" command from glibc. wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin ''; From 171882c3851e056dc882db56f7458ebb625b4b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 23:01:44 +0200 Subject: [PATCH 07/15] feat(postgresql): use systemdLibs Backport https://github.com/NixOS/nixpkgs/commit/2f9c580c6f48b8bdea941188b85389601c1ad867 --- nix/postgresql/generic.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index fd12f422f..1a5b56689 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -16,7 +16,7 @@ let icu, lz4, zstd, - systemd, + systemdLibs, libossp_uuid, pkg-config, libxml2, @@ -36,7 +36,8 @@ let libxslt, # This is important to obtain a version of `libpq` that does not depend on systemd. - systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd && !stdenv.hostPlatform.isStatic, + systemdSupport ? + lib.meta.availableOn stdenv.hostPlatform systemdLibs && !stdenv.hostPlatform.isStatic, enableSystemd ? null, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic, @@ -167,7 +168,7 @@ let ++ lib.optionals jitSupport [ llvmPackages.llvm ] ++ lib.optionals lz4Enabled [ lz4 ] ++ lib.optionals zstdEnabled [ zstd ] - ++ lib.optionals systemdSupport' [ systemd ] + ++ lib.optionals systemdSupport' [ systemdLibs ] ++ lib.optionals pythonSupport [ python3 ] ++ lib.optionals gssSupport [ libkrb5 ] ++ lib.optionals stdenv'.isLinux [ linux-pam ] From cfb7e31c28b6ee1666e0b9a979e21ed3993f8e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 23:08:49 +0200 Subject: [PATCH 08/15] feat(postgresql): postgresql_jit.pkgs.postgis: fix build on darwin Backport of upstream commit https://github.com/NixOS/nixpkgs/commit/cd85a62bc257b4177823359a20986deddaa4dc0b --- nix/postgresql/generic.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 1a5b56689..1502f8167 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -87,7 +87,7 @@ let pname = "postgresql"; stdenv' = - if jitSupport then + if jitSupport && !stdenv.cc.isClang then overrideCC llvmPackages.stdenv ( llvmPackages.stdenv.cc.override { # LLVM bintools are not used by default, but are needed to make -flto work below. @@ -208,7 +208,6 @@ let env.CFLAGS = "-fdata-sections -ffunction-sections" + (if stdenv'.cc.isClang then " -flto" else " -fmerge-constants -Wl,--gc-sections") - + lib.optionalString (stdenv'.isDarwin && jitSupport) " -fuse-ld=lld" # Makes cross-compiling work when xml2-config can't be executed on the host. # Fixed upstream in https://github.com/postgres/postgres/commit/0bc8cebdb889368abdf224aeac8bc197fe4c9ae6 + lib.optionalString (olderThan "13") " -I${libxml2.dev}/include/libxml2"; From d7b816246f07edea3d0ce03a3a7c52b4d7a28cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 23:22:02 +0200 Subject: [PATCH 09/15] feat(postgresql): improve fake pg_config in default output Backport of upstream commit https://github.com/NixOS/nixpkgs/commit/0c477676412564bd2d5dadc37cf245fe4259f4d9 --- nix/postgresql/generic.nix | 17 +++++++++-------- nix/postgresql/pg_config.sh | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 nix/postgresql/pg_config.sh diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 1502f8167..bc853cb65 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -26,6 +26,7 @@ let darwin, linux-pam, removeReferencesTo, + writeShellApplication, #orioledb specific perl, bison, @@ -96,6 +97,11 @@ let ) else stdenv; + + pg_config = writeShellApplication { + name = "pg_config"; + text = builtins.readFile ./pg_config.sh; + }; in stdenv'.mkDerivation (finalAttrs: { inherit version; @@ -294,15 +300,10 @@ let moveToOutput "lib/pgxs" "$dev" # Pretend pg_config is located in $out/bin to return correct paths, but - # actually have it in -dev to avoid pulling in all other outputs. + # actually have it in -dev to avoid pulling in all other outputs. See the + # pg_config.sh script's comments for details. moveToOutput "bin/pg_config" "$dev" - # To prevent a "pg_config: could not find own program executable" error, we fake - # pg_config in the default output. - cat << EOF > "$out/bin/pg_config" && chmod +x "$out/bin/pg_config" - #!${stdenv'.shell} - echo The real pg_config can be found in the -dev output. - exit 1 - EOF + install -c -m 755 "${pg_config}"/bin/pg_config "$out/bin/pg_config" wrapProgram "$dev/bin/pg_config" --argv0 "$out/bin/pg_config" # postgres exposes external symbols get_pkginclude_path and similar. Those diff --git a/nix/postgresql/pg_config.sh b/nix/postgresql/pg_config.sh new file mode 100644 index 000000000..9538b213f --- /dev/null +++ b/nix/postgresql/pg_config.sh @@ -0,0 +1,35 @@ +# The real pg_config needs to be in the same path as the "postgres" binary +# to return proper paths. However, we want it in the -dev output to prevent +# cyclic references and to prevent blowing up the runtime closure. Thus, we +# have wrapped -dev/bin/pg_config to fake its argv0 to be in the default +# output. Unfortunately, pg_config tries to be smart and tries to find itself - +# which will then fail with: +# pg_config: could not find own program executable +# To counter this, we're creating *this* fake pg_config script and put it into +# the default output. The real pg_config is happy. +# Some extensions, e.g. timescaledb, use the reverse logic and look for pg_config +# in the same path as the "postgres" binary to support multi-version-installs. +# Thus, they will end up calling this script during build, even though the real +# pg_config would be available on PATH, provided by nativeBuildInputs. To help +# this case, we're redirecting the call to pg_config to the one found in PATH, +# iff we can be convinced that it belongs to our -dev output. + +# Avoid infinite recursion +if [[ ! -v PG_CONFIG_CALLED ]]; then + # compares "path of *this* script" with "path, which pg_config on PATH believes it is in" + if [[ "$(readlink -f -- "$0")" == "$(PG_CONFIG_CALLED=1 pg_config --bindir)/pg_config" ]]; then + # The pg_config in PATH returns the same bindir that we're actually called from. + # This means that the pg_config in PATH is the one from "our" -dev output. + # This happens when the -dev output has been put in native build + # inputs and allows us to call the real pg_config without referencing + # the -dev output itself. + exec pg_config "$@" + fi +fi + +# This will happen in one of these cases: +# - *this* script is the first on PATH +# - np pg_config on PATH +# - some other pg_config on PATH, not from our -dev output +echo The real pg_config can be found in the -dev output. +exit 1 From 1534f076b29d12c92db39e66be8d148989e8ecfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 23:35:56 +0200 Subject: [PATCH 10/15] feat(postgresql): replace `stdenv.is` with `stdenv.hostPlatform.is` Backport upstream commit https://github.com/NixOS/nixpkgs/commit/e0464e47880a69896f0fb1810f00e0de469f770a --- nix/postgresql/generic.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index bc853cb65..f4c7d1808 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -177,8 +177,8 @@ let ++ lib.optionals systemdSupport' [ systemdLibs ] ++ lib.optionals pythonSupport [ python3 ] ++ lib.optionals gssSupport [ libkrb5 ] - ++ lib.optionals stdenv'.isLinux [ linux-pam ] - ++ lib.optionals (!stdenv'.isDarwin) [ libossp_uuid ] + ++ lib.optionals stdenv'.hostPlatform.isLinux [ linux-pam ] + ++ lib.optionals (!stdenv'.hostPlatform.isDarwin) [ libossp_uuid ] ++ lib.optionals (isOrioleDB || (lib.versionAtLeast version "17")) [ perl bison @@ -227,17 +227,19 @@ let "--with-system-tzdata=${tzdata}/share/zoneinfo" "--enable-debug" (lib.optionalString systemdSupport' "--with-systemd") - (if stdenv'.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid") + (if stdenv'.hostPlatform.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid") ] ++ lib.optionals lz4Enabled [ "--with-lz4" ] ++ lib.optionals zstdEnabled [ "--with-zstd" ] ++ lib.optionals gssSupport [ "--with-gssapi" ] ++ lib.optionals pythonSupport [ "--with-python" ] ++ lib.optionals jitSupport [ "--with-llvm" ] - ++ lib.optionals stdenv'.isLinux [ "--with-pam" ] + ++ lib.optionals stdenv'.hostPlatform.isLinux [ "--with-pam" ] # This could be removed once the upstream issue is resolved: # https://postgr.es/m/flat/427c7c25-e8e1-4fc5-a1fb-01ceff185e5b%40technowledgy.de - ++ lib.optionals (stdenv'.isDarwin && atLeast "16") [ "LDFLAGS_EX_BE=-Wl,-export_dynamic" ]; + ++ lib.optionals (stdenv'.hostPlatform.isDarwin && atLeast "16") [ + "LDFLAGS_EX_BE=-Wl,-export_dynamic" + ]; patches = [ @@ -279,10 +281,10 @@ let # Using fetchurl instead of fetchpatch on purpose: https://github.com/NixOS/nixpkgs/issues/240141 map fetchurl (lib.attrValues muslPatches) ) - ++ lib.optionals stdenv'.isLinux [ + ++ lib.optionals stdenv'.hostPlatform.isLinux [ (if atLeast "13" then ./patches/socketdir-in-run-13+.patch else ./patches/socketdir-in-run.patch) ] - ++ lib.optionals (stdenv'.isDarwin && olderThan "16") [ + ++ lib.optionals (stdenv'.hostPlatform.isDarwin && olderThan "16") [ ./patches/export-dynamic-darwin-15-.patch ]; @@ -341,7 +343,7 @@ let wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin ''; - doCheck = !stdenv'.isDarwin; + doCheck = !stdenv'.hostPlatform.isDarwin; # autodetection doesn't seem to able to find this, but it's there. checkTarget = "check"; From 8daecd429e297f6cabe98097d339f9e190a8eaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 23:40:39 +0200 Subject: [PATCH 11/15] feat(postgresql): run full test-suite during checkPhase Backport upstream commit https://github.com/NixOS/nixpkgs/commit/149aa98ce4396b972e85bb6953c8c7ccc959c6cd --- nix/postgresql/generic.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index f4c7d1808..690825f98 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -345,7 +345,7 @@ let doCheck = !stdenv'.hostPlatform.isDarwin; # autodetection doesn't seem to able to find this, but it's there. - checkTarget = "check"; + checkTarget = "check-world"; passthru = let From b1727c903ee3b155c76c4881c57fa792c57ebf16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 23:53:05 +0200 Subject: [PATCH 12/15] feat(postgresql): use newer libuuid instead of ossp-uuid Backport upstream commit https://github.com/NixOS/nixpkgs/commit/de4ad2a6ace9f2428804cf515bbc5600aa340981 --- nix/postgresql/generic.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 690825f98..63a48a6d0 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -17,7 +17,7 @@ let lz4, zstd, systemdLibs, - libossp_uuid, + libuuid, pkg-config, libxml2, tzdata, @@ -169,6 +169,7 @@ let openssl (libxml2.override { enableHttp = true; }) icu + libuuid ] ++ lib.optionals (olderThan "13") [ libxcrypt ] ++ lib.optionals jitSupport [ llvmPackages.llvm ] @@ -178,7 +179,6 @@ let ++ lib.optionals pythonSupport [ python3 ] ++ lib.optionals gssSupport [ libkrb5 ] ++ lib.optionals stdenv'.hostPlatform.isLinux [ linux-pam ] - ++ lib.optionals (!stdenv'.hostPlatform.isDarwin) [ libossp_uuid ] ++ lib.optionals (isOrioleDB || (lib.versionAtLeast version "17")) [ perl bison @@ -227,7 +227,7 @@ let "--with-system-tzdata=${tzdata}/share/zoneinfo" "--enable-debug" (lib.optionalString systemdSupport' "--with-systemd") - (if stdenv'.hostPlatform.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid") + "--with-uuid=e2fs" ] ++ lib.optionals lz4Enabled [ "--with-lz4" ] ++ lib.optionals zstdEnabled [ "--with-zstd" ] From 7176b6d629c779d41cc87407171eef1e9a048f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Mon, 21 Jul 2025 23:58:38 +0200 Subject: [PATCH 13/15] feat(postgresql): simplify systemdSupport default value Backport upstream commit https://github.com/NixOS/nixpkgs/commit/a7fdf2256ae643876035c863dc9bbd3fd95101da --- nix/postgresql/generic.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index 63a48a6d0..a426f06f0 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -36,9 +36,7 @@ let docbook_xsl_ns, libxslt, - # This is important to obtain a version of `libpq` that does not depend on systemd. - systemdSupport ? - lib.meta.availableOn stdenv.hostPlatform systemdLibs && !stdenv.hostPlatform.isStatic, + systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs, enableSystemd ? null, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic, From 6050efbd592ca442c9404702455e3af92a32ca2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Tue, 22 Jul 2025 00:01:14 +0200 Subject: [PATCH 14/15] feat(postgresql): remove deprecated enableSystemd override Backport upstream commit https://github.com/NixOS/nixpkgs/commit/6178e9bd3c37f1398f92ee433fb76e32e50ed874 --- nix/postgresql/generic.nix | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index a426f06f0..b7dc3bf57 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -37,7 +37,6 @@ let libxslt, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemdLibs, - enableSystemd ? null, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic, # for postgresql.pkgs @@ -75,12 +74,6 @@ let dlSuffix = if olderThan "16" then ".so" else stdenv.hostPlatform.extensions.sharedLibrary; - systemdSupport' = - if enableSystemd == null then - systemdSupport - else - (lib.warn "postgresql: argument enableSystemd is deprecated, please use systemdSupport instead." enableSystemd); - isOrioleDB = (builtins.match "[0-9][0-9]_.*" version) != null; pname = "postgresql"; @@ -173,7 +166,7 @@ let ++ lib.optionals jitSupport [ llvmPackages.llvm ] ++ lib.optionals lz4Enabled [ lz4 ] ++ lib.optionals zstdEnabled [ zstd ] - ++ lib.optionals systemdSupport' [ systemdLibs ] + ++ lib.optionals systemdSupport [ systemdLibs ] ++ lib.optionals pythonSupport [ python3 ] ++ lib.optionals gssSupport [ libkrb5 ] ++ lib.optionals stdenv'.hostPlatform.isLinux [ linux-pam ] @@ -224,7 +217,7 @@ let "--sysconfdir=/etc" "--with-system-tzdata=${tzdata}/share/zoneinfo" "--enable-debug" - (lib.optionalString systemdSupport' "--with-systemd") + (lib.optionalString systemdSupport "--with-systemd") "--with-uuid=e2fs" ] ++ lib.optionals lz4Enabled [ "--with-lz4" ] From 26dd9f404bcd6584e9ff828115ea43e9412b8255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Roche?= Date: Tue, 22 Jul 2025 21:26:25 +0200 Subject: [PATCH 15/15] wip --- nix/postgresql/generic.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nix/postgresql/generic.nix b/nix/postgresql/generic.nix index b7dc3bf57..788a6e50f 100644 --- a/nix/postgresql/generic.nix +++ b/nix/postgresql/generic.nix @@ -119,13 +119,11 @@ let "dev" "doc" "lib" - "man" ]; outputChecks.out = { disallowedReferences = [ "dev" "doc" - "man" ]; disallowedRequisites = [ @@ -140,8 +138,6 @@ let disallowedReferences = [ "out" "dev" - "doc" - "man" ]; disallowedRequisites = [ @@ -195,7 +191,7 @@ let separateDebugInfo = true; - buildFlags = [ "world" ]; + buildFlags = [ "world-bin" ]; # libpgcommon.a and libpgport.a contain all paths returned by pg_config and are linked # into all binaries. However, almost no binaries actually use those paths. The following @@ -279,7 +275,7 @@ let ./patches/export-dynamic-darwin-15-.patch ]; - installTargets = [ "install-world" ]; + installTargets = [ "install-world-bin" ]; postPatch = '' substituteInPlace "src/Makefile.global.in" --subst-var out @@ -305,7 +301,8 @@ let # references to -dev, -doc and -man are removed here. References to -lib must be kept, # because there is a realistic use-case for extensions to locate the /lib directory to # load other shared modules. - remove-references-to -t "$dev" -t "$doc" -t "$man" "$out/bin/postgres" + remove-references-to -t "$dev" -t "$doc" "$out/bin/postgres" + remove-references-to -t "$dev" -t "$doc" "$out/bin/pg_rewind" if [ -z "''${dontDisableStatic:-}" ]; then # Remove static libraries in case dynamic are available.