diff --git a/pkgs/servers/sql/postgresql/default.nix b/pkgs/servers/sql/postgresql/default.nix index 48b94841548ec..669502706fc94 100644 --- a/pkgs/servers/sql/postgresql/default.nix +++ b/pkgs/servers/sql/postgresql/default.nix @@ -2,9 +2,9 @@ let generic = # dependencies - { stdenv, lib, fetchurl, makeWrapper + { stdenv, lib, fetchurl, makeWrapper, fetchpatch , glibc, zlib, readline, openssl, icu, lz4, zstd, systemd, libossp_uuid - , pkg-config, libxml2, tzdata, libkrb5 + , pkg-config, libxml2, tzdata, libkrb5, substituteAll, darwin # This is important to obtain a version of `libpq` that does not depend on systemd. , enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd && !stdenv.hostPlatform.isStatic @@ -103,6 +103,24 @@ let ./patches/hardcode-pgxs-path.patch ./patches/specify_pkglibdir_at_runtime.patch ./patches/findstring.patch + + (substituteAll { + src = ./locale-binary-path.patch; + locale = "${if stdenv.isDarwin then darwin.adv_cmds else lib.getBin stdenv.cc.libc}/bin/locale"; + }) + + ] ++ lib.optionals stdenv'.hostPlatform.isMusl [ + # Fixes for musl libc + # These patches are not properly guarded and should NOT be enabled everywhere + (fetchpatch { + url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/disable-test-collate.icu.utf8.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7"; + hash = "sha256-pnl+wM3/IUyq5iJzk+h278MDA9R0GQXQX8d4wJcB2z4="; + }) + (fetchpatch { + url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/icu-collations-hack.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7"; + hash = "sha256-Yb6lMBDqeVP/BLMyIr5rmR6OkaVzo68cV/+cL2LOe/M="; + }) + ] ++ lib.optionals stdenv'.isLinux [ (if atLeast "13" then ./patches/socketdir-in-run-13.patch else ./patches/socketdir-in-run.patch) ]; diff --git a/pkgs/servers/sql/postgresql/locale-binary-path.patch b/pkgs/servers/sql/postgresql/locale-binary-path.patch new file mode 100644 index 0000000000000..08e90bce750ca --- /dev/null +++ b/pkgs/servers/sql/postgresql/locale-binary-path.patch @@ -0,0 +1,13 @@ +diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c +index fcfc02d..d011394 100644 +--- a/src/backend/commands/collationcmds.c ++++ b/src/backend/commands/collationcmds.c +@@ -611,7 +611,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS) + aliases = (CollAliasData *) palloc(maxaliases * sizeof(CollAliasData)); + naliases = 0; + +- locale_a_handle = OpenPipeStream("locale -a", "r"); ++ locale_a_handle = OpenPipeStream("@locale@ -a", "r"); + if (locale_a_handle == NULL) + ereport(ERROR, + (errcode_for_file_access(),