at 25.11-pre 141 lines 3.3 kB view raw
1{ 2 fetchFromGitHub, 3 lib, 4 nodejs_20, 5 perl, 6 postgresql, 7 postgresqlBuildExtension, 8 stdenv, 9 # For test 10 coreutils, 11 gnugrep, 12 runCommand, 13}: 14 15let 16 libv8 = nodejs_20.libv8; 17in 18postgresqlBuildExtension (finalAttrs: { 19 pname = "plv8"; 20 version = "3.2.3"; 21 22 src = fetchFromGitHub { 23 owner = "plv8"; 24 repo = "plv8"; 25 tag = "v${finalAttrs.version}"; 26 hash = "sha256-ivQZJSNn5giWF351fqZ7mBZoJkGtby5T7beK45g3Zqs="; 27 }; 28 29 patches = [ 30 # Allow building with system v8. 31 # https://github.com/plv8/plv8/pull/505 (rejected) 32 ./0001-build-Allow-using-V8-from-system.patch 33 ]; 34 35 nativeBuildInputs = [ 36 perl 37 ]; 38 39 buildInputs = [ 40 libv8 41 ]; 42 43 buildFlags = [ "all" ]; 44 45 makeFlags = [ 46 # Nixpkgs build a v8 monolith instead of separate v8_libplatform. 47 "USE_SYSTEM_V8=1" 48 "SHLIB_LINK=-lv8" 49 "V8_OUTDIR=${libv8}/lib" 50 ]; 51 52 # No configure script. 53 dontConfigure = true; 54 55 postPatch = '' 56 patchShebangs ./generate_upgrade.sh 57 ''; 58 59 passthru = { 60 tests = 61 let 62 postgresqlWithSelf = postgresql.withPackages (_: [ 63 finalAttrs.finalPackage 64 ]); 65 in 66 { 67 smoke = runCommand "plv8-smoke-test" { } '' 68 export PATH=${ 69 lib.makeBinPath [ 70 postgresqlWithSelf 71 coreutils 72 gnugrep 73 ] 74 } 75 db="$PWD/testdb" 76 initdb "$db" 77 postgres -k "$db" -D "$db" & 78 pid="$!" 79 80 for i in $(seq 1 100); do 81 if psql -h "$db" -d postgres -c "" 2>/dev/null; then 82 break 83 elif ! kill -0 "$pid"; then 84 exit 1 85 else 86 sleep 0.1 87 fi 88 done 89 90 psql -h "$db" -d postgres -c 'CREATE EXTENSION plv8; DO $$ plv8.elog(NOTICE, plv8.version); $$ LANGUAGE plv8;' 2> "$out" 91 grep -q "${finalAttrs.version}" "$out" 92 kill -0 "$pid" 93 ''; 94 95 regression = stdenv.mkDerivation { 96 name = "plv8-regression"; 97 inherit (finalAttrs) 98 src 99 patches 100 nativeBuildInputs 101 buildInputs 102 dontConfigure 103 ; 104 105 buildPhase = '' 106 runHook preBuild 107 108 # The regression tests need to be run in the order specified in the Makefile. 109 echo -e "include Makefile\nprint_regress_files:\n\t@echo \$(REGRESS)" > Makefile.regress 110 REGRESS_TESTS=$(make -f Makefile.regress print_regress_files) 111 112 ${lib.getDev postgresql}/lib/pgxs/src/test/regress/pg_regress \ 113 --bindir='${postgresqlWithSelf}/bin' \ 114 --temp-instance=regress-instance \ 115 --dbname=contrib_regression \ 116 $REGRESS_TESTS 117 118 runHook postBuild 119 ''; 120 121 installPhase = '' 122 runHook preInstall 123 124 touch "$out" 125 126 runHook postInstall 127 ''; 128 }; 129 }; 130 }; 131 132 meta = { 133 description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL"; 134 homepage = "https://plv8.github.io/"; 135 changelog = "https://github.com/plv8/plv8/blob/r${finalAttrs.version}/Changes"; 136 maintainers = [ ]; 137 platforms = postgresql.meta.platforms; 138 license = lib.licenses.postgresql; 139 broken = stdenv.hostPlatform.isDarwin; 140 }; 141})