Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions pkgs/servers/sql/postgresql/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=";
})

Comment on lines +119 to +123
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yu-re-ka @Ma27 could one of you explain why the "icu-collations-hack.patch" was introduced here?

This PR was supposed to fix pkgsMusl.postgresql building, because it was failing two tests. For this the other patch disable-test-collate.icu.utf8.patch was added. Understood.

But the lengthy text in icu-collations-hack.patch states:

Since full ICU data is very big (30 MiB), we have created a stripped down
variant
with only English locale (package icu-data-en, 2.6 MiB). It also
includes a subset of 18 collations that cover hundreds of languages.

When the cluster is initialized or pg_import_system_collations() is
called directly and only icu-data-en (default) is installed, the user
ends up with only und, en and en_GB ICU-based COLLATIONs. The user can
create missing COLLATIONs manually, but this a) is not expected nor
reasonable behaviour, b) it's not easy to find out for which locales
there's a collation available for.

(emphasis mine)

This is very specific to alpine trying to have a very small icu package. I don't think this applies for NixOS/nixpkgs at all.

I tested removing the icu-collations-hack.patch - all 5 versions still build just fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right. I was quite afraid of adding some but not all collations-related patches, and getting weird runtime behavior regarding the collations, but there was no logical reason for requiring this patch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming! I added a commit remove it in #293996.

] ++ lib.optionals stdenv'.isLinux [
(if atLeast "13" then ./patches/socketdir-in-run-13.patch else ./patches/socketdir-in-run.patch)
];
Expand Down
13 changes: 13 additions & 0 deletions pkgs/servers/sql/postgresql/locale-binary-path.patch
Original file line number Diff line number Diff line change
@@ -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(),