Skip to content

Commit ab92c98

Browse files
committed
feat: update to latest that retain plcoffee and plls and pg16
1 parent 61c6b20 commit ab92c98

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

nix/ext/plv8.nix

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
, v8
55
, perl
66
, postgresql
7-
# For test
7+
# For passthru test on various systems, and local development on macos
8+
# not we are not currently using passthru tests but retaining for possible contrib
9+
# to nixpkgs
810
, runCommand
911
, coreutils
1012
, gnugrep
13+
, clang
14+
, xcbuild
15+
, darwin
16+
, patchelf
1117
}:
1218

1319
stdenv.mkDerivation (finalAttrs: {
@@ -29,22 +35,49 @@ stdenv.mkDerivation (finalAttrs: {
2935

3036
nativeBuildInputs = [
3137
perl
38+
] ++ lib.optionals stdenv.isDarwin [
39+
clang
40+
xcbuild
3241
];
3342

3443
buildInputs = [
3544
v8
3645
postgresql
46+
] ++ lib.optionals stdenv.isDarwin [
47+
darwin.apple_sdk.frameworks.CoreFoundation
48+
darwin.apple_sdk.frameworks.Kerberos
3749
];
3850

3951
buildFlags = [ "all" ];
4052

4153
makeFlags = [
4254
# Nixpkgs build a v8 monolith instead of separate v8_libplatform.
4355
"USE_SYSTEM_V8=1"
44-
"SHLIB_LINK=-lv8"
4556
"V8_OUTDIR=${v8}/lib"
57+
"PG_CONFIG=${postgresql}/bin/pg_config"
58+
] ++ lib.optionals stdenv.isDarwin [
59+
"CC=${clang}/bin/clang"
60+
"CXX=${clang}/bin/clang++"
61+
"SHLIB_LINK=-L${v8}/lib -lv8_monolith -Wl,-rpath,${v8}/lib"
62+
] ++ lib.optionals (!stdenv.isDarwin) [
63+
"SHLIB_LINK=-lv8"
4664
];
4765

66+
NIX_LDFLAGS = (lib.optionals stdenv.isDarwin [
67+
"-L${postgresql}/lib"
68+
"-L${v8}/lib"
69+
"-lv8_monolith"
70+
"-lpq"
71+
"-lpgcommon"
72+
"-lpgport"
73+
"-F${darwin.apple_sdk.frameworks.CoreFoundation}/Library/Frameworks"
74+
"-framework" "CoreFoundation"
75+
"-F${darwin.apple_sdk.frameworks.Kerberos}/Library/Frameworks"
76+
"-framework" "Kerberos"
77+
"-undefined" "dynamic_lookup"
78+
"-flat_namespace"
79+
]);
80+
4881
installFlags = [
4982
# PGXS only supports installing to postgresql prefix so we need to redirect this
5083
"DESTDIR=${placeholder "out"}"
@@ -57,6 +90,11 @@ stdenv.mkDerivation (finalAttrs: {
5790
patchShebangs ./generate_upgrade.sh
5891
substituteInPlace generate_upgrade.sh \
5992
--replace " 2.3.10 " " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15 "
93+
94+
${lib.optionalString stdenv.isDarwin ''
95+
# Replace g++ with clang++ in Makefile
96+
sed -i 's/g++/clang++/g' Makefile
97+
''}
6098
'';
6199

62100
postInstall = ''
@@ -65,6 +103,17 @@ stdenv.mkDerivation (finalAttrs: {
65103
# so changing them does not cause issues.
66104
mv "$out/nix/store"/*/* "$out"
67105
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"
106+
107+
${lib.optionalString stdenv.isDarwin ''
108+
install_name_tool -add_rpath "${v8}/lib" $out/lib/plv8-${finalAttrs.version}.so
109+
install_name_tool -add_rpath "${postgresql}/lib" $out/lib/plv8-${finalAttrs.version}.so
110+
install_name_tool -add_rpath "${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}.so
111+
install_name_tool -change @rpath/libv8_monolith.dylib ${v8}/lib/libv8_monolith.dylib $out/lib/plv8-${finalAttrs.version}.so
112+
''}
113+
114+
${lib.optionalString (!stdenv.isDarwin) ''
115+
${patchelf}/bin/patchelf --set-rpath "${v8}/lib:${postgresql}/lib:${stdenv.cc.cc.lib}/lib" $out/lib/plv8-${finalAttrs.version}.so
116+
''}
68117
'';
69118

70119
passthru = {
@@ -134,8 +183,8 @@ stdenv.mkDerivation (finalAttrs: {
134183
meta = with lib; {
135184
description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL";
136185
homepage = "https://plv8.github.io/";
137-
maintainers = with maintainers; [ ];
138-
platforms = [ "x86_64-linux" "aarch64-linux" ];
186+
maintainers = with maintainers; [ samrose ];
187+
platforms = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ];
139188
license = licenses.postgresql;
140189
};
141190
})

0 commit comments

Comments
 (0)