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