2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, v8, perl, postgresql }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "plv8";
|
2022-01-03 16:56:52 +00:00
|
|
|
version = "3.0.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ perl ];
|
|
|
|
buildInputs = [ v8 postgresql ];
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "plv8";
|
|
|
|
repo = "plv8";
|
|
|
|
rev = "v${version}";
|
2022-01-03 16:56:52 +00:00
|
|
|
sha256 = "KJz8wnGcTXnVn6umpP+UquuJTtQrkBTJ33rB/JIH4kU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
makefile = "Makefile.shared";
|
|
|
|
|
|
|
|
buildFlags = [ "all" ];
|
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
makeFlags = [
|
|
|
|
# Nixpkgs build a v8 monolith instead of separate v8_libplatform.
|
|
|
|
"V8_OUTDIR=${v8}/lib"
|
|
|
|
];
|
|
|
|
|
|
|
|
installFlags = [
|
|
|
|
# PGXS only supports installing to postgresql prefix so we need to redirect this
|
|
|
|
"DESTDIR=${placeholder "out"}"
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preConfigure = ''
|
|
|
|
patchShebangs ./generate_upgrade.sh
|
2022-01-03 16:56:52 +00:00
|
|
|
substituteInPlace generate_upgrade.sh \
|
|
|
|
--replace " 2.3.10)" " 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.15)"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
postInstall = ''
|
|
|
|
# Move the redirected to proper directory.
|
|
|
|
# There appear to be no references to the install directories
|
|
|
|
# so changing them does not cause issues.
|
|
|
|
mv "$out/nix/store"/*/* "$out"
|
|
|
|
rmdir "$out/nix/store"/* "$out/nix/store" "$out/nix"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-01-03 16:56:52 +00:00
|
|
|
# Without this, PostgreSQL will crash at runtime.
|
|
|
|
# The flags are only included in Makefile, not Makefile.shared.
|
|
|
|
# https://github.com/plv8/plv8/pull/469
|
|
|
|
NIX_CFLAGS_COMPILE = "-DJSONB_DIRECT_CONVERSION -DV8_COMPRESS_POINTERS=1 -DV8_31BIT_SMIS_ON_64BIT_ARCH=1";
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "V8 Engine Javascript Procedural Language add-on for PostgreSQL";
|
|
|
|
homepage = "https://plv8.github.io/";
|
|
|
|
maintainers = with maintainers; [ volth marsam ];
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
license = licenses.postgresql;
|
|
|
|
};
|
|
|
|
}
|