1
1
{ stdenv
2
2
, lib
3
3
, fetchFromGitHub
4
- , v8
4
+ , nodejs_20
5
5
, perl
6
6
, postgresql
7
- # For test
7
+ # For test
8
8
, runCommand
9
9
, coreutils
10
10
, gnugrep
11
- , clang
12
- , patchelf
13
- , xcbuild
14
- , darwin
15
11
} :
16
12
17
- stdenv . mkDerivation ( finalAttrs : {
13
+ let
14
+ libv8 = nodejs_20 . libv8 ;
15
+ in stdenv . mkDerivation ( finalAttrs : {
18
16
pname = "plv8" ;
19
- version = "3.1.5 " ;
17
+ version = "3.2.2 " ;
20
18
21
19
src = fetchFromGitHub {
22
20
owner = "plv8" ;
23
21
repo = "plv8" ;
24
22
rev = "v${ finalAttrs . version } " ;
25
- hash = "sha256-LodC2eQJSm5fLckrjm2RuejZhmOyQMJTv9b0iPCnzKQ =" ;
23
+ hash = "sha256-azO33v22EF+/sTNmwswxyDR0PhrvWfTENuLu6JgSGJ0 =" ;
26
24
} ;
27
25
28
26
patches = [
27
+ # Allow building with system v8.
28
+ # https://github.com/plv8/plv8/pull/505 (rejected)
29
29
./0001-build-Allow-using-V8-from-system.patch
30
30
] ;
31
31
32
32
nativeBuildInputs = [
33
33
perl
34
- ] ++ lib . optionals stdenv . isDarwin [
35
- clang
36
- xcbuild
37
34
] ;
38
35
39
36
buildInputs = [
40
- ( v8 . overrideAttrs ( oldAttrs : {
41
- version = "9.7.106.18" ;
42
- } ) )
37
+ libv8
43
38
postgresql
44
- ] ++ lib . optionals stdenv . isDarwin [
45
- darwin . apple_sdk . frameworks . CoreFoundation
46
- darwin . apple_sdk . frameworks . Kerberos
47
39
] ;
48
40
49
41
buildFlags = [ "all" ] ;
50
42
51
43
makeFlags = [
44
+ # Nixpkgs build a v8 monolith instead of separate v8_libplatform.
52
45
"USE_SYSTEM_V8=1"
53
- "V8_OUTDIR=${ v8 } /lib"
54
- "PG_CONFIG=${ postgresql } /bin/pg_config"
55
- ] ++ lib . optionals stdenv . isDarwin [
56
- "CC=${ clang } /bin/clang"
57
- "CXX=${ clang } /bin/clang++"
58
- "SHLIB_LINK=-L${ v8 } /lib -lv8_monolith -Wl,-rpath,${ v8 } /lib"
59
- ] ++ lib . optionals ( ! stdenv . isDarwin ) [
60
- "SHLIB_LINK=-L${ v8 } /lib -lv8_monolith -Wl,-rpath,${ v8 } /lib"
61
- ] ;
62
-
63
- NIX_LDFLAGS = ( lib . optionals stdenv . isDarwin [
64
- "-L${ postgresql } /lib"
65
- "-L${ v8 } /lib"
66
- "-lv8_monolith"
67
- "-lpq"
68
- "-lpgcommon"
69
- "-lpgport"
70
- "-F${ darwin . apple_sdk . frameworks . CoreFoundation } /Library/Frameworks"
71
- "-framework" "CoreFoundation"
72
- "-F${ darwin . apple_sdk . frameworks . Kerberos } /Library/Frameworks"
73
- "-framework" "Kerberos"
74
- "-undefined" "dynamic_lookup"
75
- "-flat_namespace"
76
- ] ) ++ ( lib . optionals ( ! stdenv . isDarwin ) [
77
- "-L${ postgresql } /lib"
78
- "-L${ v8 } /lib"
79
- "-lv8_monolith"
80
- "-lpq"
81
- "-lpgcommon"
82
- "-lpgport"
83
- ] ) ;
84
-
85
- NIX_CFLAGS_COMPILE = [
86
- "-I${ v8 } /include"
87
- "-I${ postgresql } /include"
88
- "-I${ postgresql } /include/server"
89
- "-I${ postgresql } /include/internal"
46
+ "SHLIB_LINK=-lv8"
47
+ "V8_OUTDIR=${ libv8 } /lib"
90
48
] ;
91
49
92
50
installFlags = [
51
+ # PGXS only supports installing to postgresql prefix so we need to redirect this
93
52
"DESTDIR=${ placeholder "out" } "
94
53
] ;
95
54
55
+ # No configure script.
96
56
dontConfigure = true ;
97
57
98
58
postPatch = ''
99
59
patchShebangs ./generate_upgrade.sh
100
- substituteInPlace generate_upgrade.sh \
101
- --replace " 2.3.10 " " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15 "
102
-
103
- ${ lib . optionalString stdenv . isDarwin ''
104
- # Replace g++ with clang++ in Makefile
105
- sed -i 's/g++/clang++/g' Makefile
106
- '' }
107
- '' ;
108
-
109
- preBuild = lib . optionalString stdenv . isDarwin ''
110
- export CC=${ clang } /bin/clang
111
- export CXX=${ clang } /bin/clang++
112
60
'' ;
113
61
114
62
postInstall = ''
63
+ # Move the redirected to proper directory.
64
+ # There appear to be no references to the install directories
65
+ # so changing them does not cause issues.
115
66
mv "$out/nix/store"/*/* "$out"
116
67
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"
117
-
118
- ${ lib . optionalString stdenv . isDarwin ''
119
- install_name_tool -add_rpath "${ v8 } /lib" $out/lib/plv8-${ finalAttrs . version } .so
120
- install_name_tool -add_rpath "${ postgresql } /lib" $out/lib/plv8-${ finalAttrs . version } .so
121
- install_name_tool -add_rpath "${ stdenv . cc . cc . lib } /lib" $out/lib/plv8-${ finalAttrs . version } .so
122
- install_name_tool -change @rpath/libv8_monolith.dylib ${ v8 } /lib/libv8_monolith.dylib $out/lib/plv8-${ finalAttrs . version } .so
123
- '' }
124
-
125
- ${ lib . optionalString ( ! stdenv . isDarwin ) ''
126
- ${ patchelf } /bin/patchelf --set-rpath "${ v8 } /lib:${ postgresql } /lib:${ stdenv . cc . cc . lib } /lib" $out/lib/plv8-${ finalAttrs . version } .so
127
- '' }
128
68
'' ;
129
69
130
70
passthru = {
@@ -133,9 +73,8 @@ stdenv.mkDerivation (finalAttrs: {
133
73
postgresqlWithSelf = postgresql . withPackages ( _ : [
134
74
finalAttrs . finalPackage
135
75
] ) ;
136
- in
137
- {
138
- smoke = runCommand "plv8-smoke-test" { } ''
76
+ in {
77
+ smoke = runCommand "plv8-smoke-test" { } ''
139
78
export PATH=${ lib . makeBinPath [
140
79
postgresqlWithSelf
141
80
coreutils
@@ -195,9 +134,8 @@ stdenv.mkDerivation (finalAttrs: {
195
134
meta = with lib ; {
196
135
description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL" ;
197
136
homepage = "https://plv8.github.io/" ;
198
- maintainers = with maintainers ; [ samrose ] ;
199
- platforms = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ] ;
137
+ maintainers = with maintainers ; [ ] ;
138
+ platforms = [ "x86_64-linux" "aarch64-linux" ] ;
200
139
license = licenses . postgresql ;
201
- #broken = postgresql.jitSupport;
202
140
} ;
203
- } )
141
+ } )
0 commit comments