postgresql: provide plpython3 extension as package
This allows us to always build the extension, but still have the user explicitly enable it without causing rebuilds.
This commit is contained in:
parent
2888972b4f
commit
fbdb09b2cc
@ -25,6 +25,8 @@
|
|||||||
The `nixLog` function, which logs unconditionally, was also re-introduced and modified to prefix messages with the function name of the caller.
|
The `nixLog` function, which logs unconditionally, was also re-introduced and modified to prefix messages with the function name of the caller.
|
||||||
For more information, [see this PR](https://github.com/NixOS/nixpkgs/pull/370742).
|
For more information, [see this PR](https://github.com/NixOS/nixpkgs/pull/370742).
|
||||||
|
|
||||||
|
- `postgresql`'s `pythonSupport` argument has been changed. It is now enabled by default, but to use PL/Python the extension needs to be added explicitly with `postgresql.withPackages`. If you were using `postgresql.override { pythonSupport = true; }` before, change it to `postgresql.withPackages (ps: [ ps.plpython3 ])`.
|
||||||
|
|
||||||
- The `rustPlatform.fetchCargoTarball` function is deprecated, because it relied on `cargo vendor` not changing its output format to keep fixed-output derivation hashes the same, which is a Nix invariant, and Cargo 1.84.0 changed `cargo vendor`'s output format.
|
- The `rustPlatform.fetchCargoTarball` function is deprecated, because it relied on `cargo vendor` not changing its output format to keep fixed-output derivation hashes the same, which is a Nix invariant, and Cargo 1.84.0 changed `cargo vendor`'s output format.
|
||||||
It should generally be replaced with `rustPlatform.fetchCargoVendor`, but `rustPlatform.importCargoLock` may also be appropriate in some circumstances.
|
It should generally be replaced with `rustPlatform.fetchCargoVendor`, but `rustPlatform.importCargoLock` may also be appropriate in some circumstances.
|
||||||
`rustPlatform.buildRustPackage` users must set `useFetchCargoVendor` to `true` and regenerate the `cargoHash`.
|
`rustPlatform.buildRustPackage` users must set `useFetchCargoVendor` to `true` and regenerate the `cargoHash`.
|
||||||
|
@ -9,6 +9,9 @@ in
|
|||||||
// {
|
// {
|
||||||
timescaledb-apache = super.callPackage ./ext/timescaledb.nix { enableUnfree = false; };
|
timescaledb-apache = super.callPackage ./ext/timescaledb.nix { enableUnfree = false; };
|
||||||
}
|
}
|
||||||
|
// lib.optionalAttrs (!self.pythonSupport) {
|
||||||
|
plpython3 = throw "PostgreSQL extension `plpython3` is not available, because `postgresql` was built without Python support. Override with `pythonSupport = true` to enable the extension.";
|
||||||
|
}
|
||||||
// lib.optionalAttrs config.allowAliases {
|
// lib.optionalAttrs config.allowAliases {
|
||||||
pg_embedding = throw "PostgreSQL extension `pg_embedding` has been removed since the project has been abandoned. Upstream's recommendation is to use pgvector instead (https://neon.tech/docs/extensions/pg_embedding#migrate-from-pg_embedding-to-pgvector)";
|
pg_embedding = throw "PostgreSQL extension `pg_embedding` has been removed since the project has been abandoned. Upstream's recommendation is to use pgvector instead (https://neon.tech/docs/extensions/pg_embedding#migrate-from-pg_embedding-to-pgvector)";
|
||||||
}
|
}
|
||||||
|
45
pkgs/servers/sql/postgresql/ext/plpython3.nix
Normal file
45
pkgs/servers/sql/postgresql/ext/plpython3.nix
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
buildEnv,
|
||||||
|
postgresql,
|
||||||
|
postgresqlTestExtension,
|
||||||
|
python3,
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
withPackages =
|
||||||
|
f:
|
||||||
|
let
|
||||||
|
python = python3.withPackages f;
|
||||||
|
finalPackage = buildEnv {
|
||||||
|
name = "${postgresql.pname}-plpython3-${postgresql.version}";
|
||||||
|
paths = [ postgresql.plpython3 ];
|
||||||
|
passthru = {
|
||||||
|
inherit withPackages;
|
||||||
|
wrapperArgs = [
|
||||||
|
''--set PYTHONPATH "${python}/${python.sitePackages}"''
|
||||||
|
];
|
||||||
|
tests.extension = postgresqlTestExtension {
|
||||||
|
finalPackage = finalPackage.withPackages (ps: [ ps.base58 ]);
|
||||||
|
sql = ''
|
||||||
|
CREATE EXTENSION plpython3u;
|
||||||
|
DO LANGUAGE plpython3u $$
|
||||||
|
import base58
|
||||||
|
$$;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
meta = {
|
||||||
|
inherit (postgresql.meta)
|
||||||
|
homepage
|
||||||
|
license
|
||||||
|
changelog
|
||||||
|
maintainers
|
||||||
|
platforms
|
||||||
|
;
|
||||||
|
description = "PL/Python - Python Procedural Language";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
finalPackage;
|
||||||
|
in
|
||||||
|
withPackages (_: [ ])
|
@ -93,7 +93,13 @@ let
|
|||||||
perl,
|
perl,
|
||||||
|
|
||||||
# PL/Python
|
# PL/Python
|
||||||
pythonSupport ? false,
|
pythonSupport ?
|
||||||
|
lib.meta.availableOn stdenv.hostPlatform python3
|
||||||
|
# Building with python in pkgsStatic gives this error:
|
||||||
|
# checking how to link an embedded Python application... configure: error: could not find shared library for Python
|
||||||
|
&& !stdenv.hostPlatform.isStatic
|
||||||
|
# configure tries to call the python executable
|
||||||
|
&& stdenv.buildPlatform.canExecute stdenv.hostPlatform,
|
||||||
python3,
|
python3,
|
||||||
|
|
||||||
# PL/Tcl
|
# PL/Tcl
|
||||||
@ -153,7 +159,7 @@ let
|
|||||||
"doc"
|
"doc"
|
||||||
"lib"
|
"lib"
|
||||||
"man"
|
"man"
|
||||||
];
|
] ++ lib.optionals pythonSupport [ "plpython3" ];
|
||||||
outputChecks = {
|
outputChecks = {
|
||||||
out = {
|
out = {
|
||||||
disallowedReferences = [
|
disallowedReferences = [
|
||||||
@ -399,17 +405,17 @@ let
|
|||||||
# to their own output for installation, will then fail to find "postgres" during linking.
|
# to their own output for installation, will then fail to find "postgres" during linking.
|
||||||
substituteInPlace "$dev/lib/pgxs/src/Makefile.port" \
|
substituteInPlace "$dev/lib/pgxs/src/Makefile.port" \
|
||||||
--replace-fail '-bundle_loader $(bindir)/postgres' "-bundle_loader $out/bin/postgres"
|
--replace-fail '-bundle_loader $(bindir)/postgres' "-bundle_loader $out/bin/postgres"
|
||||||
'';
|
|
||||||
|
|
||||||
postFixup =
|
|
||||||
lib.optionalString stdenv'.hostPlatform.isGnu ''
|
|
||||||
# initdb needs access to "locale" command from glibc.
|
|
||||||
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
|
|
||||||
''
|
''
|
||||||
+ lib.optionalString pythonSupport ''
|
+ lib.optionalString pythonSupport ''
|
||||||
wrapProgram "$out/bin/postgres" --set PYTHONPATH "${python3}/${python3.sitePackages}"
|
moveToOutput "lib/*plpython3*" "$plpython3"
|
||||||
|
moveToOutput "share/postgresql/extension/*plpython3*" "$plpython3"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
postFixup = lib.optionalString stdenv'.hostPlatform.isGnu ''
|
||||||
|
# initdb needs access to "locale" command from glibc.
|
||||||
|
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
|
||||||
|
'';
|
||||||
|
|
||||||
# Running tests as "install check" to work around SIP issue on macOS:
|
# Running tests as "install check" to work around SIP issue on macOS:
|
||||||
# https://www.postgresql.org/message-id/flat/4D8E1BC5-BBCF-4B19-8226-359201EA8305%40gmail.com
|
# https://www.postgresql.org/message-id/flat/4D8E1BC5-BBCF-4B19-8226-359201EA8305%40gmail.com
|
||||||
# Also see <nixpkgs>/doc/stdenv/platform-notes.chapter.md
|
# Also see <nixpkgs>/doc/stdenv/platform-notes.chapter.md
|
||||||
@ -443,7 +449,7 @@ let
|
|||||||
pkgs =
|
pkgs =
|
||||||
let
|
let
|
||||||
scope = {
|
scope = {
|
||||||
inherit jitSupport;
|
inherit jitSupport pythonSupport;
|
||||||
inherit (llvmPackages) llvm;
|
inherit (llvmPackages) llvm;
|
||||||
postgresql = this;
|
postgresql = this;
|
||||||
stdenv = stdenv';
|
stdenv = stdenv';
|
||||||
@ -458,7 +464,7 @@ let
|
|||||||
import ./ext.nix newSelf newSuper;
|
import ./ext.nix newSelf newSuper;
|
||||||
|
|
||||||
withPackages = postgresqlWithPackages {
|
withPackages = postgresqlWithPackages {
|
||||||
inherit buildEnv;
|
inherit buildEnv lib makeBinaryWrapper;
|
||||||
postgresql = this;
|
postgresql = this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -506,7 +512,12 @@ let
|
|||||||
});
|
});
|
||||||
|
|
||||||
postgresqlWithPackages =
|
postgresqlWithPackages =
|
||||||
{ postgresql, buildEnv }:
|
{
|
||||||
|
postgresql,
|
||||||
|
buildEnv,
|
||||||
|
lib,
|
||||||
|
makeBinaryWrapper,
|
||||||
|
}:
|
||||||
f:
|
f:
|
||||||
let
|
let
|
||||||
installedExtensions = f postgresql.pkgs;
|
installedExtensions = f postgresql.pkgs;
|
||||||
@ -518,7 +529,19 @@ let
|
|||||||
postgresql.man # in case user installs this into environment
|
postgresql.man # in case user installs this into environment
|
||||||
];
|
];
|
||||||
|
|
||||||
pathsToLink = [ "/" ];
|
pathsToLink = [
|
||||||
|
"/"
|
||||||
|
"/bin"
|
||||||
|
];
|
||||||
|
|
||||||
|
nativeBuildInputs = [ makeBinaryWrapper ];
|
||||||
|
postBuild =
|
||||||
|
let
|
||||||
|
args = lib.concatMap (ext: ext.wrapperArgs or [ ]) installedExtensions;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
wrapProgram "$out/bin/postgres" ${lib.concatStringsSep " " args}
|
||||||
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit installedExtensions;
|
inherit installedExtensions;
|
||||||
@ -528,11 +551,11 @@ let
|
|||||||
;
|
;
|
||||||
|
|
||||||
withJIT = postgresqlWithPackages {
|
withJIT = postgresqlWithPackages {
|
||||||
inherit buildEnv;
|
inherit buildEnv lib makeBinaryWrapper;
|
||||||
postgresql = postgresql.withJIT;
|
postgresql = postgresql.withJIT;
|
||||||
} f;
|
} f;
|
||||||
withoutJIT = postgresqlWithPackages {
|
withoutJIT = postgresqlWithPackages {
|
||||||
inherit buildEnv;
|
inherit buildEnv lib makeBinaryWrapper;
|
||||||
postgresql = postgresql.withoutJIT;
|
postgresql = postgresql.withoutJIT;
|
||||||
} f;
|
} f;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user