postgresql: refactor to pass jitSupport/llvm via scope instead of passthru

This makes it less error-prone to use the llvm package in extensions, because
it will always match the package used by the postgresql derivation itself.

Previously, you could've accidentally used llvm instead of postgresql.llvm
with a different result.
This commit is contained in:
Wolfgang Walther 2024-03-02 14:04:06 +01:00
parent b301c01e31
commit 14b3ea2789
No known key found for this signature in database
GPG Key ID: B39893FA5F65CAE1
5 changed files with 10 additions and 8 deletions

View File

@ -14,7 +14,7 @@ let
# package = pkgs.postgresql_<major>;
# };
# works.
base = if cfg.enableJIT && !cfg.package.jitSupport then cfg.package.withJIT else cfg.package;
base = if cfg.enableJIT then cfg.package.withJIT else cfg.package;
in
if cfg.extraPlugins == []
then base

View File

@ -1,4 +1,4 @@
{ lib, stdenv, pg-dump-anon, postgresql, runtimeShell }:
{ lib, stdenv, pg-dump-anon, postgresql, runtimeShell, jitSupport, llvm }:
stdenv.mkDerivation (finalAttrs: {
pname = "postgresql_anonymizer";
@ -6,7 +6,7 @@ stdenv.mkDerivation (finalAttrs: {
inherit (pg-dump-anon) version src passthru;
buildInputs = [ postgresql ];
nativeBuildInputs = [ postgresql ] ++ lib.optional postgresql.jitSupport postgresql.llvm;
nativeBuildInputs = [ postgresql ] ++ lib.optional jitSupport llvm;
strictDeps = true;

View File

@ -4,6 +4,7 @@
, v8
, perl
, postgresql
, jitSupport
# For test
, runCommand
, coreutils
@ -138,6 +139,6 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = with maintainers; [ marsam ];
platforms = [ "x86_64-linux" "aarch64-linux" ];
license = licenses.postgresql;
broken = postgresql.jitSupport;
broken = jitSupport;
};
})

View File

@ -13,6 +13,8 @@
, libiconv
, pcre2
, nixosTests
, jitSupport
, llvm
}:
let
@ -31,7 +33,7 @@ stdenv.mkDerivation rec {
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2.dev ]
++ lib.optional stdenv.isDarwin libiconv;
nativeBuildInputs = [ perl pkg-config ] ++ lib.optional postgresql.jitSupport postgresql.llvm;
nativeBuildInputs = [ perl pkg-config ] ++ lib.optional jitSupport llvm;
dontDisableStatic = true;
# postgis config directory assumes /include /lib from the same root for json-c library

View File

@ -221,7 +221,6 @@ let
};
in
{
inherit jitSupport;
psqlSchema = lib.versions.major version;
withJIT = if jitSupport then this else jitToggle;
@ -231,6 +230,8 @@ let
pkgs = let
scope = {
inherit jitSupport;
inherit (llvmPackages) llvm;
postgresql = this;
stdenv = stdenv';
buildPgxExtension = buildPgxExtension.override {
@ -257,8 +258,6 @@ let
} // lib.optionalAttrs jitSupport {
postgresql-jit = nixosTests.postgresql-jit.${thisAttr};
};
} // lib.optionalAttrs jitSupport {
inherit (llvmPackages) llvm;
};
meta = with lib; {