Skip to content

Commit

Permalink
pkgsMusl.postgresql: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
yu-re-ka committed May 28, 2023
1 parent 1d5ff21 commit 8d4a81b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
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=";
})

] ++ 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(),

0 comments on commit 8d4a81b

Please sign in to comment.