postgresqlPackages.plv8: 3.0.0 → 3.1.4

https://github.com/plv8/plv8/compare/v3.0.0...v3.1.4

- Format the expression a bit.
- Had to apply a patch since upstream removed the shared Makefile.
At least we can drop the manual build flags.
- Move to a subdirectory, since we are working with multiple files now.
- Add `dontConfigure` since there is no `configure` script.
- Switch to `preConfigure` to `postPatch` as there is no configuration.

+161 -88
-87
pkgs/servers/sql/postgresql/ext/plv8.nix
··· 1 - { lib, stdenv, fetchFromGitHub, v8, perl, postgresql 2 - # For test 3 - , runCommand, coreutils, gnugrep }: 4 - 5 - let self = stdenv.mkDerivation rec { 6 - pname = "plv8"; 7 - version = "3.0.0"; 8 - 9 - nativeBuildInputs = [ perl ]; 10 - buildInputs = [ v8 postgresql ]; 11 - 12 - src = fetchFromGitHub { 13 - owner = "plv8"; 14 - repo = "plv8"; 15 - rev = "v${version}"; 16 - sha256 = "KJz8wnGcTXnVn6umpP+UquuJTtQrkBTJ33rB/JIH4kU="; 17 - }; 18 - 19 - makefile = "Makefile.shared"; 20 - 21 - buildFlags = [ "all" ]; 22 - 23 - makeFlags = [ 24 - # Nixpkgs build a v8 monolith instead of separate v8_libplatform. 25 - "V8_OUTDIR=${v8}/lib" 26 - ]; 27 - 28 - installFlags = [ 29 - # PGXS only supports installing to postgresql prefix so we need to redirect this 30 - "DESTDIR=${placeholder "out"}" 31 - ]; 32 - 33 - preConfigure = '' 34 - # We build V8 as a monolith, so this is unnecessary. 35 - substituteInPlace Makefile.shared --replace "-lv8_libplatform" "" 36 - patchShebangs ./generate_upgrade.sh 37 - substituteInPlace generate_upgrade.sh \ 38 - --replace " 2.3.10)" " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15)" 39 - ''; 40 - 41 - postInstall = '' 42 - # Move the redirected to proper directory. 43 - # There appear to be no references to the install directories 44 - # so changing them does not cause issues. 45 - mv "$out/nix/store"/*/* "$out" 46 - rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix" 47 - ''; 48 - 49 - NIX_CFLAGS_COMPILE = [ 50 - # V8 depends on C++14. 51 - "-std=c++14" 52 - # Without this, PostgreSQL will crash at runtime. 53 - # The flags are only included in Makefile, not Makefile.shared. 54 - # https://github.com/plv8/plv8/pull/469 55 - "-DJSONB_DIRECT_CONVERSION" "-DV8_COMPRESS_POINTERS=1" "-DV8_31BIT_SMIS_ON_64BIT_ARCH=1" 56 - ]; 57 - 58 - passthru.tests.smoke = runCommand "${pname}-test" {} '' 59 - export PATH=${lib.makeBinPath [ (postgresql.withPackages (_: [self])) coreutils gnugrep ]} 60 - db="$PWD/testdb" 61 - initdb "$db" 62 - postgres -k "$db" -D "$db" & 63 - pid="$!" 64 - 65 - for i in $(seq 1 100); do 66 - if psql -h "$db" -d postgres -c "" 2>/dev/null; then 67 - break 68 - elif ! kill -0 "$pid"; then 69 - exit 1 70 - else 71 - sleep 0.1 72 - fi 73 - done 74 - 75 - psql -h "$db" -d postgres -c 'CREATE EXTENSION plv8; DO $$ plv8.elog(NOTICE, plv8.version); $$ LANGUAGE plv8;' 2> "$out" 76 - grep -q "${version}" "$out" 77 - kill -0 "$pid" 78 - ''; 79 - 80 - meta = with lib; { 81 - description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL"; 82 - homepage = "https://plv8.github.io/"; 83 - maintainers = with maintainers; [ marsam ]; 84 - platforms = [ "x86_64-linux" ]; 85 - license = licenses.postgresql; 86 - }; 87 - }; in self
+47
pkgs/servers/sql/postgresql/ext/plv8/0001-build-Allow-using-V8-from-system.patch
··· 1 + diff --git a/Makefile b/Makefile 2 + index 38879cc..6e78eeb 100644 3 + --- a/Makefile 4 + +++ b/Makefile 5 + @@ -20,6 +20,7 @@ OBJS = $(SRCS:.cc=.o) 6 + MODULE_big = plv8-$(PLV8_VERSION) 7 + EXTENSION = plv8 8 + PLV8_DATA = plv8.control plv8--$(PLV8_VERSION).sql $(wildcard upgrade/*.sql) 9 + +USE_SYSTEM_V8 = 0 10 + 11 + 12 + # Platform detection 13 + @@ -41,6 +42,7 @@ PGXS := $(shell $(PG_CONFIG) --pgxs) 14 + PG_VERSION_NUM := $(shell cat `$(PG_CONFIG) --includedir-server`/pg_config*.h \ 15 + | perl -ne 'print $$1 and exit if /PG_VERSION_NUM\s+(\d+)/') 16 + 17 + +ifeq ($(USE_SYSTEM_V8),0) 18 + AUTOV8_DIR = build/v8 19 + AUTOV8_OUT = build/v8/out.gn/obj 20 + AUTOV8_STATIC_LIBS = -lv8_libplatform -lv8_libbase 21 + @@ -66,6 +68,7 @@ v8: 22 + make -f Makefiles/Makefile.macos v8 23 + endif 24 + endif 25 + +endif 26 + 27 + # enable direct jsonb conversion by default 28 + CCFLAGS += -DJSONB_DIRECT_CONVERSION 29 + @@ -83,6 +86,7 @@ ifdef BIGINT_GRACEFUL 30 + endif 31 + 32 + 33 + +ifeq ($(USE_SYSTEM_V8),0) 34 + # We're gonna build static link. Rip it out after include Makefile 35 + SHLIB_LINK := $(filter-out -lv8, $(SHLIB_LINK)) 36 + 37 + @@ -101,6 +105,7 @@ else 38 + SHLIB_LINK += -lrt -std=c++14 39 + endif 40 + endif 41 + +endif 42 + 43 + DATA = $(PLV8_DATA) 44 + ifndef DISABLE_DIALECT 45 + -- 46 + 2.37.3 47 +
+113
pkgs/servers/sql/postgresql/ext/plv8/default.nix
··· 1 + { stdenv 2 + , lib 3 + , fetchFromGitHub 4 + , v8 5 + , perl 6 + , postgresql 7 + # For test 8 + , runCommand 9 + , coreutils 10 + , gnugrep 11 + }: 12 + 13 + stdenv.mkDerivation (finalAttrs: { 14 + pname = "plv8"; 15 + version = "3.1.4"; 16 + 17 + src = fetchFromGitHub { 18 + owner = "plv8"; 19 + repo = "plv8"; 20 + rev = "v${finalAttrs.version}"; 21 + sha256 = "GoPP2nAeDItBt3Lug49s+brD0gIy3iDlJpbyHRuMcZ4="; 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 + }; 105 + 106 + meta = with lib; { 107 + description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL"; 108 + homepage = "https://plv8.github.io/"; 109 + maintainers = with maintainers; [ marsam ]; 110 + platforms = [ "x86_64-linux" ]; 111 + license = licenses.postgresql; 112 + }; 113 + })
+1 -1
pkgs/servers/sql/postgresql/packages.nix
··· 32 32 33 33 plr = super.callPackage ./ext/plr.nix { }; 34 34 35 - plv8 = super.callPackage ./ext/plv8.nix { 35 + plv8 = super.callPackage ./ext/plv8 { 36 36 v8 = self.v8_8_x; 37 37 }; 38 38