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