22 stdenv ,
33 lib ,
44 fetchFromGitHub ,
5- nodejs ,
65 perl ,
76 postgresql ,
87 # For passthru test on various systems, and local development on macos
1312 darwin ,
1413 patchelf ,
1514} :
16-
15+ let
16+ # plv8 3.1 requires an older version of v8 (we cannot use nodejs.libv8)
17+ node_pkgs = import ( fetchTarball {
18+ url = "https://github.com/nixos/nixpkgs/archive/a76c4553d7e741e17f289224eda135423de0491d.tar.gz" ;
19+ sha256 = "0rwdzp942b8ay625lqgra83qrp64b3wqm6w9a0i4z593df8x822v" ;
20+ } ) { system = stdenv . system ; } ;
21+ inherit ( node_pkgs ) v8 ;
22+ in
1723stdenv . mkDerivation ( finalAttrs : {
1824 pname = "plv8" ;
1925 version = "3.1.10" ;
@@ -40,7 +46,7 @@ stdenv.mkDerivation (finalAttrs: {
4046
4147 buildInputs =
4248 [
43- nodejs . libv8
49+ v8
4450 postgresql
4551 ]
4652 ++ lib . optionals stdenv . isDarwin [
@@ -54,20 +60,20 @@ stdenv.mkDerivation (finalAttrs: {
5460 [
5561 # Nixpkgs build a v8 monolith instead of separate v8_libplatform.
5662 "USE_SYSTEM_V8=1"
57- "V8_OUTDIR=${ nodejs . libv8 } /lib"
63+ "V8_OUTDIR=${ v8 } /lib"
5864 "PG_CONFIG=${ postgresql } /bin/pg_config"
5965 ]
6066 ++ lib . optionals stdenv . isDarwin [
6167 "CC=${ clang } /bin/clang"
6268 "CXX=${ clang } /bin/clang++"
63- "SHLIB_LINK=-L${ nodejs . libv8 } /lib -lv8_monolith -Wl,-rpath,${ nodejs . libv8 } /lib"
69+ "SHLIB_LINK=-L${ v8 } /lib -lv8_monolith -Wl,-rpath,${ v8 } /lib"
6470 ]
6571 ++ lib . optionals ( ! stdenv . isDarwin ) [ "SHLIB_LINK=-lv8" ] ;
6672
6773 NIX_LDFLAGS = (
6874 lib . optionals stdenv . isDarwin [
6975 "-L${ postgresql } /lib"
70- "-L${ nodejs . libv8 } /lib"
76+ "-L${ v8 } /lib"
7177 "-lv8_monolith"
7278 "-lpq"
7379 "-lpgcommon"
@@ -119,25 +125,25 @@ stdenv.mkDerivation (finalAttrs: {
119125 sed -i 's|module_pathname = '"'"'$libdir/plv8-[0-9.]*'"'"'|module_pathname = '"'"'$libdir/plv8'"'"'|' "$out/share/postgresql/extension/plls.control"
120126
121127 ${ lib . optionalString stdenv . isDarwin ''
122- install_name_tool -add_rpath "${ nodejs . libv8 } /lib" $out/lib/plv8.so
128+ install_name_tool -add_rpath "${ v8 } /lib" $out/lib/plv8.so
123129 install_name_tool -add_rpath "${ postgresql } /lib" $out/lib/plv8.so
124130 install_name_tool -add_rpath "${ stdenv . cc . cc . lib } /lib" $out/lib/plv8.so
125- install_name_tool -change @rpath/libv8_monolith.dylib ${ nodejs . libv8 } /lib/libv8_monolith.dylib $out/lib/plv8.so
131+ install_name_tool -change @rpath/libv8_monolith.dylib ${ v8 } /lib/libv8_monolith.dylib $out/lib/plv8.so
126132 '' }
127133
128134 ${ lib . optionalString ( ! stdenv . isDarwin ) ''
129- ${ patchelf } /bin/patchelf --set-rpath "${ nodejs . libv8 } /lib:${ postgresql } /lib:${ stdenv . cc . cc . lib } /lib" $out/lib/plv8.so
135+ ${ patchelf } /bin/patchelf --set-rpath "${ v8 } /lib:${ postgresql } /lib:${ stdenv . cc . cc . lib } /lib" $out/lib/plv8.so
130136 '' }
131137 else
132138 ${ lib . optionalString stdenv . isDarwin ''
133- install_name_tool -add_rpath "${ nodejs . libv8 } /lib" $out/lib/plv8-${ finalAttrs . version } ${ postgresql . dlSuffix }
139+ install_name_tool -add_rpath "${ v8 } /lib" $out/lib/plv8-${ finalAttrs . version } ${ postgresql . dlSuffix }
134140 install_name_tool -add_rpath "${ postgresql } /lib" $out/lib/plv8-${ finalAttrs . version } ${ postgresql . dlSuffix }
135141 install_name_tool -add_rpath "${ stdenv . cc . cc . lib } /lib" $out/lib/plv8-${ finalAttrs . version } ${ postgresql . dlSuffix }
136- install_name_tool -change @rpath/libv8_monolith.dylib ${ nodejs . libv8 } /lib/libv8_monolith.dylib $out/lib/plv8-${ finalAttrs . version } ${ postgresql . dlSuffix }
142+ install_name_tool -change @rpath/libv8_monolith.dylib ${ v8 } /lib/libv8_monolith.dylib $out/lib/plv8-${ finalAttrs . version } ${ postgresql . dlSuffix }
137143 '' }
138144
139145 ${ lib . optionalString ( ! stdenv . isDarwin ) ''
140- ${ patchelf } /bin/patchelf --set-rpath "${ nodejs . libv8 } /lib:${ postgresql } /lib:${ stdenv . cc . cc . lib } /lib" $out/lib/plv8-${ finalAttrs . version } ${ postgresql . dlSuffix }
146+ ${ patchelf } /bin/patchelf --set-rpath "${ v8 } /lib:${ postgresql } /lib:${ stdenv . cc . cc . lib } /lib" $out/lib/plv8-${ finalAttrs . version } ${ postgresql . dlSuffix }
141147 '' }
142148 fi
143149 '' ;
0 commit comments