Merge pull request #292993 from wolfgangwalther/postgresql-refactor
postgresql: refactor and cleanup
This commit is contained in:
commit
6af7e814af
16 changed files with 517 additions and 522 deletions
|
@ -277,7 +277,7 @@ self: super: {
|
||||||
Here's a recipe on how to override a particular plugin through an overlay:
|
Here's a recipe on how to override a particular plugin through an overlay:
|
||||||
```
|
```
|
||||||
self: super: {
|
self: super: {
|
||||||
postgresql_15 = super.postgresql_15.override { this = self.postgresql_15; } // {
|
postgresql_15 = super.postgresql_15// {
|
||||||
pkgs = super.postgresql_15.pkgs // {
|
pkgs = super.postgresql_15.pkgs // {
|
||||||
pg_repack = super.postgresql_15.pkgs.pg_repack.overrideAttrs (_: {
|
pg_repack = super.postgresql_15.pkgs.pg_repack.overrideAttrs (_: {
|
||||||
name = "pg_repack-v20181024";
|
name = "pg_repack-v20181024";
|
||||||
|
|
|
@ -14,7 +14,7 @@ let
|
||||||
# package = pkgs.postgresql_<major>;
|
# package = pkgs.postgresql_<major>;
|
||||||
# };
|
# };
|
||||||
# works.
|
# 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
|
in
|
||||||
if cfg.extraPlugins == []
|
if cfg.extraPlugins == []
|
||||||
then base
|
then base
|
||||||
|
|
10
pkgs/servers/sql/postgresql/12.nix
Normal file
10
pkgs/servers/sql/postgresql/12.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import ./generic.nix {
|
||||||
|
version = "12.18";
|
||||||
|
hash = "sha256-T5kZcl2UHOmGjgf+HtHTqGdIWZtIM4ZUdYOSi3TDkYo=";
|
||||||
|
muslPatches = {
|
||||||
|
icu-collations-hack = {
|
||||||
|
url = "https://git.alpinelinux.org/aports/plain/testing/postgresql12/icu-collations-hack.patch?id=d5227c91adda59d4e7f55f13468f0314e8869174";
|
||||||
|
hash = "sha256-wuwjvGHArkRNwFo40g3p43W32OrJohretlt6iSRlJKg=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
14
pkgs/servers/sql/postgresql/13.nix
Normal file
14
pkgs/servers/sql/postgresql/13.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import ./generic.nix {
|
||||||
|
version = "13.14";
|
||||||
|
hash = "sha256-uN8HhVGJiWC9UA3F04oXfpkFN234H+fytmChQH+mpe0=";
|
||||||
|
muslPatches = {
|
||||||
|
icu-collations-hack = {
|
||||||
|
url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/icu-collations-hack.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7";
|
||||||
|
hash = "sha256-wuwjvGHArkRNwFo40g3p43W32OrJohretlt6iSRlJKg=";
|
||||||
|
};
|
||||||
|
disable-test-collate-icu-utf8 = {
|
||||||
|
url = "https://git.alpinelinux.org/aports/plain/main/postgresql13/disable-test-collate.icu.utf8.patch?id=69faa146ec9fff3b981511068f17f9e629d4688b";
|
||||||
|
hash = "sha256-jS/qxezaiaKhkWeMCXwpz1SDJwUWn9tzN0uKaZ3Ph2Y=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
14
pkgs/servers/sql/postgresql/14.nix
Normal file
14
pkgs/servers/sql/postgresql/14.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import ./generic.nix {
|
||||||
|
version = "14.11";
|
||||||
|
hash = "sha256-pnC9fc4i3K1Cl7JhE2s7HUoJpvVBcZViqhTKY78paKg=";
|
||||||
|
muslPatches = {
|
||||||
|
icu-collations-hack = {
|
||||||
|
url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/icu-collations-hack.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7";
|
||||||
|
hash = "sha256-wuwjvGHArkRNwFo40g3p43W32OrJohretlt6iSRlJKg=";
|
||||||
|
};
|
||||||
|
disable-test-collate-icu-utf8 = {
|
||||||
|
url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/disable-test-collate.icu.utf8.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7";
|
||||||
|
hash = "sha256-jXe23AxnFjEl+TZQm4R7rStk2Leo08ctxMNmu1xr5zM=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
10
pkgs/servers/sql/postgresql/15.nix
Normal file
10
pkgs/servers/sql/postgresql/15.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import ./generic.nix {
|
||||||
|
version = "15.6";
|
||||||
|
hash = "sha256-hFUUbtnGnJOlfelUrq0DAsr60DXCskIXXWqh4X68svs=";
|
||||||
|
muslPatches = {
|
||||||
|
icu-collations-hack = {
|
||||||
|
url = "https://git.alpinelinux.org/aports/plain/main/postgresql15/icu-collations-hack.patch?id=f424e934e6d076c4ae065ce45e734aa283eecb9c";
|
||||||
|
hash = "sha256-HgtmhF4OJYU9macGJbTB9PjQi/yW7c3Akm3U0niWs8I=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
10
pkgs/servers/sql/postgresql/16.nix
Normal file
10
pkgs/servers/sql/postgresql/16.nix
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
import ./generic.nix {
|
||||||
|
version = "16.2";
|
||||||
|
hash = "sha256-RG6IKU28LJCFq0twYaZG+mBLS+wDUh1epnHC5a2bKVI=";
|
||||||
|
muslPatches = {
|
||||||
|
icu-collations-hack = {
|
||||||
|
url = "https://git.alpinelinux.org/aports/plain/main/postgresql16/icu-collations-hack.patch?id=08a24be262339fd093e641860680944c3590238e";
|
||||||
|
hash = "sha256-+urQdVIlADLdDPeT68XYv5rljhbK8M/7mPZn/cF+FT0=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,412 +1,24 @@
|
||||||
|
self:
|
||||||
let
|
let
|
||||||
|
versions = {
|
||||||
generic =
|
postgresql_12 = ./12.nix;
|
||||||
# dependencies
|
postgresql_13 = ./13.nix;
|
||||||
{ stdenv, lib, fetchurl, makeWrapper, fetchpatch
|
postgresql_14 = ./14.nix;
|
||||||
, glibc, zlib, readline, openssl, icu, lz4, zstd, systemd, libossp_uuid
|
postgresql_15 = ./15.nix;
|
||||||
, pkg-config, libxml2, tzdata, libkrb5, substituteAll, darwin
|
postgresql_16 = ./16.nix;
|
||||||
, linux-pam
|
|
||||||
|
|
||||||
# This is important to obtain a version of `libpq` that does not depend on systemd.
|
|
||||||
, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd && !stdenv.hostPlatform.isStatic
|
|
||||||
, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic
|
|
||||||
|
|
||||||
# for postgresql.pkgs
|
|
||||||
, this, self, newScope, buildEnv
|
|
||||||
|
|
||||||
# source specification
|
|
||||||
, version, hash, psqlSchema
|
|
||||||
|
|
||||||
# for tests
|
|
||||||
, testers, nixosTests, thisAttr
|
|
||||||
|
|
||||||
# JIT
|
|
||||||
, jitSupport ? false
|
|
||||||
, nukeReferences, patchelf, llvmPackages
|
|
||||||
, makeRustPlatform, buildPgxExtension, cargo, rustc
|
|
||||||
|
|
||||||
# PL/Python
|
|
||||||
, pythonSupport ? false
|
|
||||||
, python3
|
|
||||||
|
|
||||||
# detection of crypt fails when using llvm stdenv, so we add it manually
|
|
||||||
# for <13 (where it got removed: https://github.com/postgres/postgres/commit/c45643d618e35ec2fe91438df15abd4f3c0d85ca)
|
|
||||||
, libxcrypt
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
atLeast = lib.versionAtLeast version;
|
|
||||||
olderThan = lib.versionOlder version;
|
|
||||||
lz4Enabled = atLeast "14";
|
|
||||||
zstdEnabled = atLeast "15";
|
|
||||||
|
|
||||||
pname = "postgresql";
|
|
||||||
|
|
||||||
stdenv' = if jitSupport then llvmPackages.stdenv else stdenv;
|
|
||||||
in stdenv'.mkDerivation (finalAttrs: {
|
|
||||||
inherit pname version;
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "mirror://postgresql/source/v${version}/${pname}-${version}.tar.bz2";
|
|
||||||
inherit hash;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
hardeningEnable = lib.optionals (!stdenv'.cc.isClang) [ "pie" ];
|
mkAttributes = jitSupport:
|
||||||
|
self.lib.mapAttrs' (version: path:
|
||||||
outputs = [ "out" "lib" "doc" "man" ];
|
let
|
||||||
setOutputFlags = false; # $out retains configureFlags :-/
|
attrName = if jitSupport then "${version}_jit" else version;
|
||||||
|
in
|
||||||
buildInputs = [
|
self.lib.nameValuePair attrName (import path {
|
||||||
zlib
|
inherit jitSupport self;
|
||||||
readline
|
thisAttr = attrName;
|
||||||
openssl
|
|
||||||
libxml2
|
|
||||||
icu
|
|
||||||
]
|
|
||||||
++ lib.optionals (olderThan "13") [ libxcrypt ]
|
|
||||||
++ lib.optionals jitSupport [ llvmPackages.llvm ]
|
|
||||||
++ lib.optionals lz4Enabled [ lz4 ]
|
|
||||||
++ lib.optionals zstdEnabled [ zstd ]
|
|
||||||
++ lib.optionals enableSystemd [ systemd ]
|
|
||||||
++ lib.optionals pythonSupport [ python3 ]
|
|
||||||
++ lib.optionals gssSupport [ libkrb5 ]
|
|
||||||
++ lib.optionals stdenv'.isLinux [ linux-pam ]
|
|
||||||
++ lib.optionals (!stdenv'.isDarwin) [ libossp_uuid ];
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
makeWrapper
|
|
||||||
pkg-config
|
|
||||||
]
|
|
||||||
++ lib.optionals jitSupport [ llvmPackages.llvm.dev nukeReferences patchelf ];
|
|
||||||
|
|
||||||
enableParallelBuilding = !stdenv'.isDarwin;
|
|
||||||
|
|
||||||
separateDebugInfo = true;
|
|
||||||
|
|
||||||
buildFlags = [ "world" ];
|
|
||||||
|
|
||||||
env.NIX_CFLAGS_COMPILE = "-I${libxml2.dev}/include/libxml2";
|
|
||||||
|
|
||||||
# Otherwise it retains a reference to compiler and fails; see #44767. TODO: better.
|
|
||||||
preConfigure = "CC=${stdenv'.cc.targetPrefix}cc";
|
|
||||||
|
|
||||||
configureFlags = [
|
|
||||||
"--with-openssl"
|
|
||||||
"--with-libxml"
|
|
||||||
"--with-icu"
|
|
||||||
"--sysconfdir=/etc"
|
|
||||||
"--libdir=$(lib)/lib"
|
|
||||||
"--with-system-tzdata=${tzdata}/share/zoneinfo"
|
|
||||||
"--enable-debug"
|
|
||||||
(lib.optionalString enableSystemd "--with-systemd")
|
|
||||||
(if stdenv'.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid")
|
|
||||||
] ++ lib.optionals lz4Enabled [ "--with-lz4" ]
|
|
||||||
++ lib.optionals zstdEnabled [ "--with-zstd" ]
|
|
||||||
++ lib.optionals gssSupport [ "--with-gssapi" ]
|
|
||||||
++ lib.optionals pythonSupport [ "--with-python" ]
|
|
||||||
++ lib.optionals stdenv'.hostPlatform.isRiscV [ "--disable-spinlocks" ]
|
|
||||||
++ lib.optionals jitSupport [ "--with-llvm" ]
|
|
||||||
++ lib.optionals stdenv'.isLinux [ "--with-pam" ];
|
|
||||||
|
|
||||||
patches = [
|
|
||||||
(if atLeast "16" then ./patches/disable-normalize_exec_path.patch
|
|
||||||
else ./patches/disable-resolve_symlinks.patch)
|
|
||||||
./patches/less-is-more.patch
|
|
||||||
./patches/hardcode-pgxs-path.patch
|
|
||||||
./patches/specify_pkglibdir_at_runtime.patch
|
|
||||||
./patches/findstring.patch
|
|
||||||
|
|
||||||
(substituteAll {
|
|
||||||
src = ./locale-binary-path.patch;
|
|
||||||
locale = "${if stdenv.isDarwin then darwin.adv_cmds else lib.getBin stdenv.cc.libc}/bin/locale";
|
|
||||||
})
|
})
|
||||||
|
) versions;
|
||||||
|
|
||||||
] ++ lib.optionals stdenv'.hostPlatform.isMusl (
|
in
|
||||||
let
|
# variations without and with JIT
|
||||||
self = {
|
(mkAttributes false) // (mkAttributes true)
|
||||||
"12" = {
|
|
||||||
icu-collations-hack = fetchurl {
|
|
||||||
url = "https://git.alpinelinux.org/aports/plain/testing/postgresql12/icu-collations-hack.patch?id=d5227c91adda59d4e7f55f13468f0314e8869174";
|
|
||||||
hash = "sha256-wuwjvGHArkRNwFo40g3p43W32OrJohretlt6iSRlJKg=";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"13" = {
|
|
||||||
inherit (self."14") icu-collations-hack;
|
|
||||||
disable-test-collate-icu-utf8 = fetchurl {
|
|
||||||
url = "https://git.alpinelinux.org/aports/plain/main/postgresql13/disable-test-collate.icu.utf8.patch?id=69faa146ec9fff3b981511068f17f9e629d4688b";
|
|
||||||
hash = "sha256-jS/qxezaiaKhkWeMCXwpz1SDJwUWn9tzN0uKaZ3Ph2Y=";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"14" = {
|
|
||||||
icu-collations-hack = fetchurl {
|
|
||||||
url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/icu-collations-hack.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7";
|
|
||||||
hash = "sha256-wuwjvGHArkRNwFo40g3p43W32OrJohretlt6iSRlJKg=";
|
|
||||||
};
|
|
||||||
disable-test-collate-icu-utf8 = fetchurl {
|
|
||||||
url = "https://git.alpinelinux.org/aports/plain/main/postgresql14/disable-test-collate.icu.utf8.patch?id=56999e6d0265ceff5c5239f85fdd33e146f06cb7";
|
|
||||||
hash = "sha256-jXe23AxnFjEl+TZQm4R7rStk2Leo08ctxMNmu1xr5zM=";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"15" = {
|
|
||||||
icu-collations-hack = fetchurl {
|
|
||||||
url = "https://git.alpinelinux.org/aports/plain/main/postgresql15/icu-collations-hack.patch?id=f424e934e6d076c4ae065ce45e734aa283eecb9c";
|
|
||||||
hash = "sha256-HgtmhF4OJYU9macGJbTB9PjQi/yW7c3Akm3U0niWs8I=";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
"16" = {
|
|
||||||
icu-collations-hack = fetchurl {
|
|
||||||
url = "https://git.alpinelinux.org/aports/plain/main/postgresql16/icu-collations-hack.patch?id=08a24be262339fd093e641860680944c3590238e";
|
|
||||||
hash = "sha256-+urQdVIlADLdDPeT68XYv5rljhbK8M/7mPZn/cF+FT0=";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
patchesForVersion = self.${lib.versions.major version} or (throw "no musl patches for postgresql ${version}");
|
|
||||||
in
|
|
||||||
lib.attrValues patchesForVersion
|
|
||||||
) ++ lib.optionals stdenv'.isLinux [
|
|
||||||
(if atLeast "13" then ./patches/socketdir-in-run-13.patch else ./patches/socketdir-in-run.patch)
|
|
||||||
];
|
|
||||||
|
|
||||||
installTargets = [ "install-world" ];
|
|
||||||
|
|
||||||
LC_ALL = "C";
|
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
# Hardcode the path to pgxs so pg_config returns the path in $out
|
|
||||||
substituteInPlace "src/common/config_info.c" --replace HARDCODED_PGXS_PATH "$out/lib"
|
|
||||||
'' + lib.optionalString jitSupport ''
|
|
||||||
# Force lookup of jit stuff in $out instead of $lib
|
|
||||||
substituteInPlace src/backend/jit/jit.c --replace pkglib_path \"$out/lib\"
|
|
||||||
substituteInPlace src/backend/jit/llvm/llvmjit.c --replace pkglib_path \"$out/lib\"
|
|
||||||
substituteInPlace src/backend/jit/llvm/llvmjit_inline.cpp --replace pkglib_path \"$out/lib\"
|
|
||||||
'';
|
|
||||||
|
|
||||||
postInstall =
|
|
||||||
''
|
|
||||||
moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
|
|
||||||
moveToOutput "lib/libpgcommon*.a" "$out"
|
|
||||||
moveToOutput "lib/libpgport*.a" "$out"
|
|
||||||
moveToOutput "lib/libecpg*" "$out"
|
|
||||||
|
|
||||||
# Prevent a retained dependency on gcc-wrapper.
|
|
||||||
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/ld ld
|
|
||||||
|
|
||||||
if [ -z "''${dontDisableStatic:-}" ]; then
|
|
||||||
# Remove static libraries in case dynamic are available.
|
|
||||||
for i in $out/lib/*.a $lib/lib/*.a; do
|
|
||||||
name="$(basename "$i")"
|
|
||||||
ext="${stdenv'.hostPlatform.extensions.sharedLibrary}"
|
|
||||||
if [ -e "$lib/lib/''${name%.a}$ext" ] || [ -e "''${i%.a}$ext" ]; then
|
|
||||||
rm "$i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
'' + lib.optionalString jitSupport ''
|
|
||||||
# Move the bitcode and libllvmjit.so library out of $lib; otherwise, every client that
|
|
||||||
# depends on libpq.so will also have libLLVM.so in its closure too, bloating it
|
|
||||||
moveToOutput "lib/bitcode" "$out"
|
|
||||||
moveToOutput "lib/llvmjit*" "$out"
|
|
||||||
|
|
||||||
# In the case of JIT support, prevent a retained dependency on clang-wrapper
|
|
||||||
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${self.llvmPackages.stdenv.cc}/bin/clang clang
|
|
||||||
nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f)
|
|
||||||
|
|
||||||
# Stop out depending on the default output of llvm
|
|
||||||
substituteInPlace $out/lib/pgxs/src/Makefile.global \
|
|
||||||
--replace ${self.llvmPackages.llvm.out}/bin "" \
|
|
||||||
--replace '$(LLVM_BINPATH)/' ""
|
|
||||||
|
|
||||||
# Stop out depending on the -dev output of llvm
|
|
||||||
substituteInPlace $out/lib/pgxs/src/Makefile.global \
|
|
||||||
--replace ${self.llvmPackages.llvm.dev}/bin/llvm-config llvm-config \
|
|
||||||
--replace -I${self.llvmPackages.llvm.dev}/include ""
|
|
||||||
|
|
||||||
${lib.optionalString (!stdenv'.isDarwin) ''
|
|
||||||
# Stop lib depending on the -dev output of llvm
|
|
||||||
rpath=$(patchelf --print-rpath $out/lib/llvmjit.so)
|
|
||||||
nuke-refs -e $out $out/lib/llvmjit.so
|
|
||||||
# Restore the correct rpath
|
|
||||||
patchelf $out/lib/llvmjit.so --set-rpath "$rpath"
|
|
||||||
''}
|
|
||||||
'';
|
|
||||||
|
|
||||||
postFixup = lib.optionalString (!stdenv'.isDarwin && stdenv'.hostPlatform.libc == "glibc")
|
|
||||||
''
|
|
||||||
# initdb needs access to "locale" command from glibc.
|
|
||||||
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
|
|
||||||
'';
|
|
||||||
|
|
||||||
doCheck = !stdenv'.isDarwin;
|
|
||||||
# autodetection doesn't seem to able to find this, but it's there.
|
|
||||||
checkTarget = "check";
|
|
||||||
|
|
||||||
preCheck =
|
|
||||||
# On musl, comment skip the following tests, because they break due to
|
|
||||||
# ! ERROR: could not load library "/build/postgresql-11.5/tmp_install/nix/store/...-postgresql-11.5-lib/lib/libpqwalreceiver.so": Error loading shared library libpq.so.5: No such file or directory (needed by /build/postgresql-11.5/tmp_install/nix/store/...-postgresql-11.5-lib/lib/libpqwalreceiver.so)
|
|
||||||
# See also here:
|
|
||||||
# https://git.alpinelinux.org/aports/tree/main/postgresql/disable-broken-tests.patch?id=6d7d32c12e073a57a9e5946e55f4c1fbb68bd442
|
|
||||||
if stdenv'.hostPlatform.isMusl then ''
|
|
||||||
substituteInPlace src/test/regress/parallel_schedule \
|
|
||||||
--replace "subscription" "" \
|
|
||||||
--replace "object_address" ""
|
|
||||||
'' else null;
|
|
||||||
|
|
||||||
doInstallCheck = false; # needs a running daemon?
|
|
||||||
|
|
||||||
disallowedReferences = [ stdenv'.cc ];
|
|
||||||
|
|
||||||
passthru = let
|
|
||||||
jitToggle = this.override {
|
|
||||||
jitSupport = !jitSupport;
|
|
||||||
this = jitToggle;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit readline psqlSchema jitSupport;
|
|
||||||
|
|
||||||
withJIT = if jitSupport then this else jitToggle;
|
|
||||||
withoutJIT = if jitSupport then jitToggle else this;
|
|
||||||
|
|
||||||
dlSuffix = if olderThan "16" then ".so" else stdenv.hostPlatform.extensions.sharedLibrary;
|
|
||||||
|
|
||||||
pkgs = let
|
|
||||||
scope = {
|
|
||||||
postgresql = this;
|
|
||||||
stdenv = stdenv';
|
|
||||||
buildPgxExtension = buildPgxExtension.override {
|
|
||||||
stdenv = stdenv';
|
|
||||||
rustPlatform = makeRustPlatform {
|
|
||||||
stdenv = stdenv';
|
|
||||||
inherit rustc cargo;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
newSelf = self // scope;
|
|
||||||
newSuper = { callPackage = newScope (scope // this.pkgs); };
|
|
||||||
in import ./packages.nix newSelf newSuper;
|
|
||||||
|
|
||||||
withPackages = postgresqlWithPackages {
|
|
||||||
inherit makeWrapper buildEnv;
|
|
||||||
postgresql = this;
|
|
||||||
}
|
|
||||||
this.pkgs;
|
|
||||||
|
|
||||||
tests = {
|
|
||||||
postgresql = nixosTests.postgresql-wal-receiver.${thisAttr};
|
|
||||||
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
|
||||||
} // lib.optionalAttrs jitSupport {
|
|
||||||
postgresql-jit = nixosTests.postgresql-jit.${thisAttr};
|
|
||||||
};
|
|
||||||
} // lib.optionalAttrs jitSupport {
|
|
||||||
inherit (llvmPackages) llvm;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
homepage = "https://www.postgresql.org";
|
|
||||||
description = "A powerful, open source object-relational database system";
|
|
||||||
license = licenses.postgresql;
|
|
||||||
changelog = "https://www.postgresql.org/docs/release/${finalAttrs.version}/";
|
|
||||||
maintainers = with maintainers; [ thoughtpolice danbst globin marsam ivan ma27 ];
|
|
||||||
pkgConfigModules = [ "libecpg" "libecpg_compat" "libpgtypes" "libpq" ];
|
|
||||||
platforms = platforms.unix;
|
|
||||||
|
|
||||||
# JIT support doesn't work with cross-compilation. It is attempted to build LLVM-bytecode
|
|
||||||
# (`%.bc` is the corresponding `make(1)`-rule) for each sub-directory in `backend/` for
|
|
||||||
# the JIT apparently, but with a $(CLANG) that can produce binaries for the build, not the
|
|
||||||
# host-platform.
|
|
||||||
#
|
|
||||||
# I managed to get a cross-build with JIT support working with
|
|
||||||
# `depsBuildBuild = [ llvmPackages.clang ] ++ buildInputs`, but considering that the
|
|
||||||
# resulting LLVM IR isn't platform-independent this doesn't give you much.
|
|
||||||
# In fact, I tried to test the result in a VM-test, but as soon as JIT was used to optimize
|
|
||||||
# a query, postgres would coredump with `Illegal instruction`.
|
|
||||||
broken = jitSupport && (stdenv.hostPlatform != stdenv.buildPlatform);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
postgresqlWithPackages = { postgresql, makeWrapper, buildEnv }: pkgs: f: buildEnv {
|
|
||||||
name = "postgresql-and-plugins-${postgresql.version}";
|
|
||||||
paths = f pkgs ++ [
|
|
||||||
postgresql
|
|
||||||
postgresql.lib
|
|
||||||
postgresql.man # in case user installs this into environment
|
|
||||||
];
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
|
||||||
|
|
||||||
|
|
||||||
# We include /bin to ensure the $out/bin directory is created, which is
|
|
||||||
# needed because we'll be removing the files from that directory in postBuild
|
|
||||||
# below. See #22653
|
|
||||||
pathsToLink = ["/" "/bin"];
|
|
||||||
|
|
||||||
# Note: the duplication of executables is about 4MB size.
|
|
||||||
# So a nicer solution was patching postgresql to allow setting the
|
|
||||||
# libdir explicitly.
|
|
||||||
postBuild = ''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
rm $out/bin/{pg_config,postgres,pg_ctl}
|
|
||||||
cp --target-directory=$out/bin ${postgresql}/bin/{postgres,pg_config,pg_ctl}
|
|
||||||
wrapProgram $out/bin/postgres --set NIX_PGLIBDIR $out/lib
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru.version = postgresql.version;
|
|
||||||
passthru.psqlSchema = postgresql.psqlSchema;
|
|
||||||
};
|
|
||||||
|
|
||||||
mkPackages = self: {
|
|
||||||
postgresql_12 = self.callPackage generic {
|
|
||||||
version = "12.18";
|
|
||||||
psqlSchema = "12";
|
|
||||||
hash = "sha256-T5kZcl2UHOmGjgf+HtHTqGdIWZtIM4ZUdYOSi3TDkYo=";
|
|
||||||
this = self.postgresql_12;
|
|
||||||
thisAttr = "postgresql_12";
|
|
||||||
inherit self;
|
|
||||||
};
|
|
||||||
|
|
||||||
postgresql_13 = self.callPackage generic {
|
|
||||||
version = "13.14";
|
|
||||||
psqlSchema = "13";
|
|
||||||
hash = "sha256-uN8HhVGJiWC9UA3F04oXfpkFN234H+fytmChQH+mpe0=";
|
|
||||||
this = self.postgresql_13;
|
|
||||||
thisAttr = "postgresql_13";
|
|
||||||
inherit self;
|
|
||||||
};
|
|
||||||
|
|
||||||
postgresql_14 = self.callPackage generic {
|
|
||||||
version = "14.11";
|
|
||||||
psqlSchema = "14";
|
|
||||||
hash = "sha256-pnC9fc4i3K1Cl7JhE2s7HUoJpvVBcZViqhTKY78paKg=";
|
|
||||||
this = self.postgresql_14;
|
|
||||||
thisAttr = "postgresql_14";
|
|
||||||
inherit self;
|
|
||||||
};
|
|
||||||
|
|
||||||
postgresql_15 = self.callPackage generic {
|
|
||||||
version = "15.6";
|
|
||||||
psqlSchema = "15";
|
|
||||||
hash = "sha256-hFUUbtnGnJOlfelUrq0DAsr60DXCskIXXWqh4X68svs=";
|
|
||||||
this = self.postgresql_15;
|
|
||||||
thisAttr = "postgresql_15";
|
|
||||||
inherit self;
|
|
||||||
};
|
|
||||||
|
|
||||||
postgresql_16 = self.callPackage generic {
|
|
||||||
version = "16.2";
|
|
||||||
psqlSchema = "16";
|
|
||||||
hash = "sha256-RG6IKU28LJCFq0twYaZG+mBLS+wDUh1epnHC5a2bKVI=";
|
|
||||||
this = self.postgresql_16;
|
|
||||||
thisAttr = "postgresql_16";
|
|
||||||
inherit self;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
in self:
|
|
||||||
let packages = mkPackages self; in
|
|
||||||
packages
|
|
||||||
// self.lib.mapAttrs'
|
|
||||||
(attrName: postgres: self.lib.nameValuePair "${attrName}_jit" (postgres.override rec {
|
|
||||||
jitSupport = true;
|
|
||||||
thisAttr = "${attrName}_jit";
|
|
||||||
this = self.${thisAttr};
|
|
||||||
}))
|
|
||||||
packages
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, stdenv, pg-dump-anon, postgresql, runtimeShell }:
|
{ lib, stdenv, pg-dump-anon, postgresql, runtimeShell, jitSupport, llvm }:
|
||||||
|
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "postgresql_anonymizer";
|
pname = "postgresql_anonymizer";
|
||||||
|
@ -6,7 +6,7 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
inherit (pg-dump-anon) version src passthru;
|
inherit (pg-dump-anon) version src passthru;
|
||||||
|
|
||||||
buildInputs = [ postgresql ];
|
buildInputs = [ postgresql ];
|
||||||
nativeBuildInputs = [ postgresql ] ++ lib.optional postgresql.jitSupport postgresql.llvm;
|
nativeBuildInputs = [ postgresql ] ++ lib.optional jitSupport llvm;
|
||||||
|
|
||||||
strictDeps = true;
|
strictDeps = true;
|
||||||
|
|
||||||
|
|
107
pkgs/servers/sql/postgresql/ext/default.nix
Normal file
107
pkgs/servers/sql/postgresql/ext/default.nix
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
self: super: {
|
||||||
|
|
||||||
|
age = super.callPackage ./age.nix { };
|
||||||
|
|
||||||
|
anonymizer = super.callPackage ./anonymizer.nix { };
|
||||||
|
|
||||||
|
apache_datasketches = super.callPackage ./apache_datasketches.nix { };
|
||||||
|
|
||||||
|
citus = super.callPackage ./citus.nix { };
|
||||||
|
|
||||||
|
h3-pg = super.callPackage ./h3-pg.nix { };
|
||||||
|
|
||||||
|
hypopg = super.callPackage ./hypopg.nix { };
|
||||||
|
|
||||||
|
jsonb_deep_sum = super.callPackage ./jsonb_deep_sum.nix { };
|
||||||
|
|
||||||
|
lantern = super.callPackage ./lantern.nix { };
|
||||||
|
|
||||||
|
periods = super.callPackage ./periods.nix { };
|
||||||
|
|
||||||
|
postgis = super.callPackage ./postgis.nix { };
|
||||||
|
|
||||||
|
pg_auto_failover = super.callPackage ./pg_auto_failover.nix { };
|
||||||
|
|
||||||
|
pg_bigm = super.callPackage ./pg_bigm.nix { };
|
||||||
|
|
||||||
|
pg_ed25519 = super.callPackage ./pg_ed25519.nix { };
|
||||||
|
|
||||||
|
pg_embedding = super.callPackage ./pg_embedding.nix { };
|
||||||
|
|
||||||
|
pg_hint_plan = super.callPackage ./pg_hint_plan.nix { };
|
||||||
|
|
||||||
|
pg_ivm = super.callPackage ./pg_ivm.nix { };
|
||||||
|
|
||||||
|
pg_rational = super.callPackage ./pg_rational.nix { };
|
||||||
|
|
||||||
|
pg_repack = super.callPackage ./pg_repack.nix { };
|
||||||
|
|
||||||
|
pg_similarity = super.callPackage ./pg_similarity.nix { };
|
||||||
|
|
||||||
|
pgaudit = super.callPackage ./pgaudit.nix { };
|
||||||
|
|
||||||
|
pgroonga = super.callPackage ./pgroonga.nix { };
|
||||||
|
|
||||||
|
pgsodium = super.callPackage ./pgsodium.nix { };
|
||||||
|
|
||||||
|
pgsql-http = super.callPackage ./pgsql-http.nix { };
|
||||||
|
|
||||||
|
pgvecto-rs = super.callPackage ./pgvecto-rs { };
|
||||||
|
|
||||||
|
pgvector = super.callPackage ./pgvector.nix { };
|
||||||
|
|
||||||
|
plpgsql_check = super.callPackage ./plpgsql_check.nix { };
|
||||||
|
|
||||||
|
plr = super.callPackage ./plr.nix { };
|
||||||
|
|
||||||
|
plv8 = super.callPackage ./plv8 { };
|
||||||
|
|
||||||
|
pgjwt = super.callPackage ./pgjwt.nix { };
|
||||||
|
|
||||||
|
cstore_fdw = super.callPackage ./cstore_fdw.nix { };
|
||||||
|
|
||||||
|
pg_hll = super.callPackage ./pg_hll.nix { };
|
||||||
|
|
||||||
|
pg_cron = super.callPackage ./pg_cron.nix { };
|
||||||
|
|
||||||
|
pg_topn = super.callPackage ./pg_topn.nix { };
|
||||||
|
|
||||||
|
pg_net = super.callPackage ./pg_net.nix { };
|
||||||
|
|
||||||
|
pgtap = super.callPackage ./pgtap.nix { };
|
||||||
|
|
||||||
|
smlar = super.callPackage ./smlar.nix { };
|
||||||
|
|
||||||
|
temporal_tables = super.callPackage ./temporal_tables.nix { };
|
||||||
|
|
||||||
|
timescaledb = super.callPackage ./timescaledb.nix { };
|
||||||
|
timescaledb-apache = super.callPackage ./timescaledb.nix { enableUnfree = false; };
|
||||||
|
|
||||||
|
timescaledb_toolkit = super.callPackage ./timescaledb_toolkit.nix { };
|
||||||
|
|
||||||
|
tsearch_extras = super.callPackage ./tsearch_extras.nix { };
|
||||||
|
|
||||||
|
tds_fdw = super.callPackage ./tds_fdw.nix { };
|
||||||
|
|
||||||
|
pgrouting = super.callPackage ./pgrouting.nix { };
|
||||||
|
|
||||||
|
pg_partman = super.callPackage ./pg_partman.nix { };
|
||||||
|
|
||||||
|
pg_relusage = super.callPackage ./pg_relusage.nix { };
|
||||||
|
|
||||||
|
pg_safeupdate = super.callPackage ./pg_safeupdate.nix { };
|
||||||
|
|
||||||
|
pg_squeeze = super.callPackage ./pg_squeeze.nix { };
|
||||||
|
|
||||||
|
pg_uuidv7 = super.callPackage ./pg_uuidv7.nix { };
|
||||||
|
|
||||||
|
promscale_extension = super.callPackage ./promscale_extension.nix { };
|
||||||
|
|
||||||
|
repmgr = super.callPackage ./repmgr.nix { };
|
||||||
|
|
||||||
|
rum = super.callPackage ./rum.nix { };
|
||||||
|
|
||||||
|
tsja = super.callPackage ./tsja.nix { };
|
||||||
|
|
||||||
|
wal2json = super.callPackage ./wal2json.nix { };
|
||||||
|
}
|
|
@ -4,6 +4,7 @@
|
||||||
, v8
|
, v8
|
||||||
, perl
|
, perl
|
||||||
, postgresql
|
, postgresql
|
||||||
|
, jitSupport
|
||||||
# For test
|
# For test
|
||||||
, runCommand
|
, runCommand
|
||||||
, coreutils
|
, coreutils
|
||||||
|
@ -138,6 +139,6 @@ stdenv.mkDerivation (finalAttrs: {
|
||||||
maintainers = with maintainers; [ marsam ];
|
maintainers = with maintainers; [ marsam ];
|
||||||
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
platforms = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
license = licenses.postgresql;
|
license = licenses.postgresql;
|
||||||
broken = postgresql.jitSupport;
|
broken = jitSupport;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
, libiconv
|
, libiconv
|
||||||
, pcre2
|
, pcre2
|
||||||
, nixosTests
|
, nixosTests
|
||||||
|
, jitSupport
|
||||||
|
, llvm
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -31,7 +33,7 @@ stdenv.mkDerivation rec {
|
||||||
|
|
||||||
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2.dev ]
|
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2.dev ]
|
||||||
++ lib.optional stdenv.isDarwin libiconv;
|
++ 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;
|
dontDisableStatic = true;
|
||||||
|
|
||||||
# postgis config directory assumes /include /lib from the same root for json-c library
|
# postgis config directory assumes /include /lib from the same root for json-c library
|
||||||
|
|
322
pkgs/servers/sql/postgresql/generic.nix
Normal file
322
pkgs/servers/sql/postgresql/generic.nix
Normal file
|
@ -0,0 +1,322 @@
|
||||||
|
let
|
||||||
|
|
||||||
|
generic =
|
||||||
|
# dependencies
|
||||||
|
{ stdenv, lib, fetchurl, makeWrapper, fetchpatch
|
||||||
|
, glibc, zlib, readline, openssl, icu, lz4, zstd, systemd, libossp_uuid
|
||||||
|
, pkg-config, libxml2, tzdata, libkrb5, substituteAll, darwin
|
||||||
|
, linux-pam
|
||||||
|
|
||||||
|
# This is important to obtain a version of `libpq` that does not depend on systemd.
|
||||||
|
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd && !stdenv.hostPlatform.isStatic
|
||||||
|
, enableSystemd ? null
|
||||||
|
, gssSupport ? with stdenv.hostPlatform; !isWindows && !isStatic
|
||||||
|
|
||||||
|
# for postgresql.pkgs
|
||||||
|
, self, newScope, buildEnv
|
||||||
|
|
||||||
|
# source specification
|
||||||
|
, version, hash, muslPatches
|
||||||
|
|
||||||
|
# for tests
|
||||||
|
, testers, nixosTests, thisAttr
|
||||||
|
|
||||||
|
# JIT
|
||||||
|
, jitSupport
|
||||||
|
, nukeReferences, patchelf, llvmPackages
|
||||||
|
, makeRustPlatform, buildPgxExtension, cargo, rustc
|
||||||
|
|
||||||
|
# PL/Python
|
||||||
|
, pythonSupport ? false
|
||||||
|
, python3
|
||||||
|
|
||||||
|
# detection of crypt fails when using llvm stdenv, so we add it manually
|
||||||
|
# for <13 (where it got removed: https://github.com/postgres/postgres/commit/c45643d618e35ec2fe91438df15abd4f3c0d85ca)
|
||||||
|
, libxcrypt
|
||||||
|
} @args:
|
||||||
|
let
|
||||||
|
atLeast = lib.versionAtLeast version;
|
||||||
|
olderThan = lib.versionOlder version;
|
||||||
|
lz4Enabled = atLeast "14";
|
||||||
|
zstdEnabled = atLeast "15";
|
||||||
|
|
||||||
|
systemdSupport' = if enableSystemd == null then systemdSupport else (lib.warn "postgresql: argument enableSystemd is deprecated, please use systemdSupport instead." enableSystemd);
|
||||||
|
|
||||||
|
pname = "postgresql";
|
||||||
|
|
||||||
|
stdenv' = if jitSupport then llvmPackages.stdenv else stdenv;
|
||||||
|
in stdenv'.mkDerivation (finalAttrs: {
|
||||||
|
inherit pname version;
|
||||||
|
|
||||||
|
src = fetchurl {
|
||||||
|
url = "mirror://postgresql/source/v${version}/${pname}-${version}.tar.bz2";
|
||||||
|
inherit hash;
|
||||||
|
};
|
||||||
|
|
||||||
|
hardeningEnable = lib.optionals (!stdenv'.cc.isClang) [ "pie" ];
|
||||||
|
|
||||||
|
outputs = [ "out" "lib" "doc" "man" ];
|
||||||
|
setOutputFlags = false; # $out retains configureFlags :-/
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
zlib
|
||||||
|
readline
|
||||||
|
openssl
|
||||||
|
libxml2
|
||||||
|
icu
|
||||||
|
]
|
||||||
|
++ lib.optionals (olderThan "13") [ libxcrypt ]
|
||||||
|
++ lib.optionals jitSupport [ llvmPackages.llvm ]
|
||||||
|
++ lib.optionals lz4Enabled [ lz4 ]
|
||||||
|
++ lib.optionals zstdEnabled [ zstd ]
|
||||||
|
++ lib.optionals systemdSupport' [ systemd ]
|
||||||
|
++ lib.optionals pythonSupport [ python3 ]
|
||||||
|
++ lib.optionals gssSupport [ libkrb5 ]
|
||||||
|
++ lib.optionals stdenv'.isLinux [ linux-pam ]
|
||||||
|
++ lib.optionals (!stdenv'.isDarwin) [ libossp_uuid ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
makeWrapper
|
||||||
|
pkg-config
|
||||||
|
]
|
||||||
|
++ lib.optionals jitSupport [ llvmPackages.llvm.dev nukeReferences patchelf ];
|
||||||
|
|
||||||
|
enableParallelBuilding = !stdenv'.isDarwin;
|
||||||
|
|
||||||
|
separateDebugInfo = true;
|
||||||
|
|
||||||
|
buildFlags = [ "world" ];
|
||||||
|
|
||||||
|
env.NIX_CFLAGS_COMPILE = "-I${libxml2.dev}/include/libxml2";
|
||||||
|
|
||||||
|
# Otherwise it retains a reference to compiler and fails; see #44767. TODO: better.
|
||||||
|
preConfigure = "CC=${stdenv'.cc.targetPrefix}cc";
|
||||||
|
|
||||||
|
configureFlags = [
|
||||||
|
"--with-openssl"
|
||||||
|
"--with-libxml"
|
||||||
|
"--with-icu"
|
||||||
|
"--sysconfdir=/etc"
|
||||||
|
"--libdir=$(lib)/lib"
|
||||||
|
"--with-system-tzdata=${tzdata}/share/zoneinfo"
|
||||||
|
"--enable-debug"
|
||||||
|
(lib.optionalString systemdSupport' "--with-systemd")
|
||||||
|
(if stdenv'.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid")
|
||||||
|
] ++ lib.optionals lz4Enabled [ "--with-lz4" ]
|
||||||
|
++ lib.optionals zstdEnabled [ "--with-zstd" ]
|
||||||
|
++ lib.optionals gssSupport [ "--with-gssapi" ]
|
||||||
|
++ lib.optionals pythonSupport [ "--with-python" ]
|
||||||
|
++ lib.optionals stdenv'.hostPlatform.isRiscV [ "--disable-spinlocks" ]
|
||||||
|
++ lib.optionals jitSupport [ "--with-llvm" ]
|
||||||
|
++ lib.optionals stdenv'.isLinux [ "--with-pam" ];
|
||||||
|
|
||||||
|
patches = [
|
||||||
|
(if atLeast "16" then ./patches/disable-normalize_exec_path.patch
|
||||||
|
else ./patches/disable-resolve_symlinks.patch)
|
||||||
|
./patches/less-is-more.patch
|
||||||
|
./patches/hardcode-pgxs-path.patch
|
||||||
|
./patches/specify_pkglibdir_at_runtime.patch
|
||||||
|
./patches/findstring.patch
|
||||||
|
|
||||||
|
(substituteAll {
|
||||||
|
src = ./patches/locale-binary-path.patch;
|
||||||
|
locale = "${if stdenv.isDarwin then darwin.adv_cmds else lib.getBin stdenv.cc.libc}/bin/locale";
|
||||||
|
})
|
||||||
|
|
||||||
|
] ++ lib.optionals stdenv'.hostPlatform.isMusl (
|
||||||
|
# Using fetchurl instead of fetchpatch on purpose: https://github.com/NixOS/nixpkgs/issues/240141
|
||||||
|
map fetchurl (lib.attrValues muslPatches)
|
||||||
|
) ++ lib.optionals stdenv'.isLinux [
|
||||||
|
(if atLeast "13" then ./patches/socketdir-in-run-13.patch else ./patches/socketdir-in-run.patch)
|
||||||
|
];
|
||||||
|
|
||||||
|
installTargets = [ "install-world" ];
|
||||||
|
|
||||||
|
LC_ALL = "C";
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
# Hardcode the path to pgxs so pg_config returns the path in $out
|
||||||
|
substituteInPlace "src/common/config_info.c" --replace HARDCODED_PGXS_PATH "$out/lib"
|
||||||
|
'' + lib.optionalString jitSupport ''
|
||||||
|
# Force lookup of jit stuff in $out instead of $lib
|
||||||
|
substituteInPlace src/backend/jit/jit.c --replace pkglib_path \"$out/lib\"
|
||||||
|
substituteInPlace src/backend/jit/llvm/llvmjit.c --replace pkglib_path \"$out/lib\"
|
||||||
|
substituteInPlace src/backend/jit/llvm/llvmjit_inline.cpp --replace pkglib_path \"$out/lib\"
|
||||||
|
'';
|
||||||
|
|
||||||
|
postInstall =
|
||||||
|
''
|
||||||
|
moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
|
||||||
|
moveToOutput "lib/libpgcommon*.a" "$out"
|
||||||
|
moveToOutput "lib/libpgport*.a" "$out"
|
||||||
|
moveToOutput "lib/libecpg*" "$out"
|
||||||
|
|
||||||
|
# Prevent a retained dependency on gcc-wrapper.
|
||||||
|
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/ld ld
|
||||||
|
|
||||||
|
if [ -z "''${dontDisableStatic:-}" ]; then
|
||||||
|
# Remove static libraries in case dynamic are available.
|
||||||
|
for i in $out/lib/*.a $lib/lib/*.a; do
|
||||||
|
name="$(basename "$i")"
|
||||||
|
ext="${stdenv'.hostPlatform.extensions.sharedLibrary}"
|
||||||
|
if [ -e "$lib/lib/''${name%.a}$ext" ] || [ -e "''${i%.a}$ext" ]; then
|
||||||
|
rm "$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
'' + lib.optionalString jitSupport ''
|
||||||
|
# Move the bitcode and libllvmjit.so library out of $lib; otherwise, every client that
|
||||||
|
# depends on libpq.so will also have libLLVM.so in its closure too, bloating it
|
||||||
|
moveToOutput "lib/bitcode" "$out"
|
||||||
|
moveToOutput "lib/llvmjit*" "$out"
|
||||||
|
|
||||||
|
# In the case of JIT support, prevent a retained dependency on clang-wrapper
|
||||||
|
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv'.cc}/bin/clang clang
|
||||||
|
nuke-refs $out/lib/llvmjit_types.bc $(find $out/lib/bitcode -type f)
|
||||||
|
|
||||||
|
# Stop out depending on the default output of llvm
|
||||||
|
substituteInPlace $out/lib/pgxs/src/Makefile.global \
|
||||||
|
--replace ${llvmPackages.llvm.out}/bin "" \
|
||||||
|
--replace '$(LLVM_BINPATH)/' ""
|
||||||
|
|
||||||
|
# Stop out depending on the -dev output of llvm
|
||||||
|
substituteInPlace $out/lib/pgxs/src/Makefile.global \
|
||||||
|
--replace ${llvmPackages.llvm.dev}/bin/llvm-config llvm-config \
|
||||||
|
--replace -I${llvmPackages.llvm.dev}/include ""
|
||||||
|
|
||||||
|
${lib.optionalString (!stdenv'.isDarwin) ''
|
||||||
|
# Stop lib depending on the -dev output of llvm
|
||||||
|
rpath=$(patchelf --print-rpath $out/lib/llvmjit.so)
|
||||||
|
nuke-refs -e $out $out/lib/llvmjit.so
|
||||||
|
# Restore the correct rpath
|
||||||
|
patchelf $out/lib/llvmjit.so --set-rpath "$rpath"
|
||||||
|
''}
|
||||||
|
'';
|
||||||
|
|
||||||
|
postFixup = lib.optionalString (!stdenv'.isDarwin && stdenv'.hostPlatform.libc == "glibc")
|
||||||
|
''
|
||||||
|
# initdb needs access to "locale" command from glibc.
|
||||||
|
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = !stdenv'.isDarwin;
|
||||||
|
# autodetection doesn't seem to able to find this, but it's there.
|
||||||
|
checkTarget = "check";
|
||||||
|
|
||||||
|
preCheck =
|
||||||
|
# On musl, comment skip the following tests, because they break due to
|
||||||
|
# ! ERROR: could not load library "/build/postgresql-11.5/tmp_install/nix/store/...-postgresql-11.5-lib/lib/libpqwalreceiver.so": Error loading shared library libpq.so.5: No such file or directory (needed by /build/postgresql-11.5/tmp_install/nix/store/...-postgresql-11.5-lib/lib/libpqwalreceiver.so)
|
||||||
|
# See also here:
|
||||||
|
# https://git.alpinelinux.org/aports/tree/main/postgresql/disable-broken-tests.patch?id=6d7d32c12e073a57a9e5946e55f4c1fbb68bd442
|
||||||
|
if stdenv'.hostPlatform.isMusl then ''
|
||||||
|
substituteInPlace src/test/regress/parallel_schedule \
|
||||||
|
--replace "subscription" "" \
|
||||||
|
--replace "object_address" ""
|
||||||
|
'' else null;
|
||||||
|
|
||||||
|
disallowedReferences = [ stdenv'.cc ];
|
||||||
|
|
||||||
|
passthru = let
|
||||||
|
this = self.callPackage generic args;
|
||||||
|
jitToggle = this.override {
|
||||||
|
jitSupport = !jitSupport;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
psqlSchema = lib.versions.major version;
|
||||||
|
|
||||||
|
withJIT = if jitSupport then this else jitToggle;
|
||||||
|
withoutJIT = if jitSupport then jitToggle else this;
|
||||||
|
|
||||||
|
dlSuffix = if olderThan "16" then ".so" else stdenv.hostPlatform.extensions.sharedLibrary;
|
||||||
|
|
||||||
|
pkgs = let
|
||||||
|
scope = {
|
||||||
|
inherit jitSupport;
|
||||||
|
inherit (llvmPackages) llvm;
|
||||||
|
postgresql = this;
|
||||||
|
stdenv = stdenv';
|
||||||
|
buildPgxExtension = buildPgxExtension.override {
|
||||||
|
stdenv = stdenv';
|
||||||
|
rustPlatform = makeRustPlatform {
|
||||||
|
stdenv = stdenv';
|
||||||
|
inherit rustc cargo;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
newSelf = self // scope;
|
||||||
|
newSuper = { callPackage = newScope (scope // this.pkgs); };
|
||||||
|
in import ./ext newSelf newSuper;
|
||||||
|
|
||||||
|
withPackages = postgresqlWithPackages {
|
||||||
|
inherit makeWrapper buildEnv;
|
||||||
|
postgresql = this;
|
||||||
|
}
|
||||||
|
this.pkgs;
|
||||||
|
|
||||||
|
tests = {
|
||||||
|
postgresql = nixosTests.postgresql-wal-receiver.${thisAttr};
|
||||||
|
pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
|
||||||
|
} // lib.optionalAttrs jitSupport {
|
||||||
|
postgresql-jit = nixosTests.postgresql-jit.${thisAttr};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
homepage = "https://www.postgresql.org";
|
||||||
|
description = "A powerful, open source object-relational database system";
|
||||||
|
license = licenses.postgresql;
|
||||||
|
changelog = "https://www.postgresql.org/docs/release/${finalAttrs.version}/";
|
||||||
|
maintainers = with maintainers; [ thoughtpolice danbst globin marsam ivan ma27 ];
|
||||||
|
pkgConfigModules = [ "libecpg" "libecpg_compat" "libpgtypes" "libpq" ];
|
||||||
|
platforms = platforms.unix;
|
||||||
|
|
||||||
|
# JIT support doesn't work with cross-compilation. It is attempted to build LLVM-bytecode
|
||||||
|
# (`%.bc` is the corresponding `make(1)`-rule) for each sub-directory in `backend/` for
|
||||||
|
# the JIT apparently, but with a $(CLANG) that can produce binaries for the build, not the
|
||||||
|
# host-platform.
|
||||||
|
#
|
||||||
|
# I managed to get a cross-build with JIT support working with
|
||||||
|
# `depsBuildBuild = [ llvmPackages.clang ] ++ buildInputs`, but considering that the
|
||||||
|
# resulting LLVM IR isn't platform-independent this doesn't give you much.
|
||||||
|
# In fact, I tried to test the result in a VM-test, but as soon as JIT was used to optimize
|
||||||
|
# a query, postgres would coredump with `Illegal instruction`.
|
||||||
|
broken = jitSupport && (stdenv.hostPlatform != stdenv.buildPlatform);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
postgresqlWithPackages = { postgresql, makeWrapper, buildEnv }: pkgs: f: buildEnv {
|
||||||
|
name = "postgresql-and-plugins-${postgresql.version}";
|
||||||
|
paths = f pkgs ++ [
|
||||||
|
postgresql
|
||||||
|
postgresql.lib
|
||||||
|
postgresql.man # in case user installs this into environment
|
||||||
|
];
|
||||||
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
|
|
||||||
|
# We include /bin to ensure the $out/bin directory is created, which is
|
||||||
|
# needed because we'll be removing the files from that directory in postBuild
|
||||||
|
# below. See #22653
|
||||||
|
pathsToLink = ["/" "/bin"];
|
||||||
|
|
||||||
|
# Note: the duplication of executables is about 4MB size.
|
||||||
|
# So a nicer solution was patching postgresql to allow setting the
|
||||||
|
# libdir explicitly.
|
||||||
|
postBuild = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
rm $out/bin/{pg_config,postgres,pg_ctl}
|
||||||
|
cp --target-directory=$out/bin ${postgresql}/bin/{postgres,pg_config,pg_ctl}
|
||||||
|
wrapProgram $out/bin/postgres --set NIX_PGLIBDIR $out/lib
|
||||||
|
'';
|
||||||
|
|
||||||
|
passthru.version = postgresql.version;
|
||||||
|
passthru.psqlSchema = postgresql.psqlSchema;
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
# passed by <major>.nix
|
||||||
|
versionArgs:
|
||||||
|
# passed by default.nix
|
||||||
|
{ self, ... } @defaultArgs:
|
||||||
|
self.callPackage generic (defaultArgs // versionArgs)
|
|
@ -1,107 +0,0 @@
|
||||||
self: super: {
|
|
||||||
|
|
||||||
age = super.callPackage ./ext/age.nix { };
|
|
||||||
|
|
||||||
anonymizer = super.callPackage ./ext/anonymizer.nix { };
|
|
||||||
|
|
||||||
apache_datasketches = super.callPackage ./ext/apache_datasketches.nix { };
|
|
||||||
|
|
||||||
citus = super.callPackage ./ext/citus.nix { };
|
|
||||||
|
|
||||||
h3-pg = super.callPackage ./ext/h3-pg.nix { };
|
|
||||||
|
|
||||||
hypopg = super.callPackage ./ext/hypopg.nix { };
|
|
||||||
|
|
||||||
jsonb_deep_sum = super.callPackage ./ext/jsonb_deep_sum.nix { };
|
|
||||||
|
|
||||||
lantern = super.callPackage ./ext/lantern.nix { };
|
|
||||||
|
|
||||||
periods = super.callPackage ./ext/periods.nix { };
|
|
||||||
|
|
||||||
postgis = super.callPackage ./ext/postgis.nix { };
|
|
||||||
|
|
||||||
pg_auto_failover = super.callPackage ./ext/pg_auto_failover.nix { };
|
|
||||||
|
|
||||||
pg_bigm = super.callPackage ./ext/pg_bigm.nix { };
|
|
||||||
|
|
||||||
pg_ed25519 = super.callPackage ./ext/pg_ed25519.nix { };
|
|
||||||
|
|
||||||
pg_embedding = super.callPackage ./ext/pg_embedding.nix { };
|
|
||||||
|
|
||||||
pg_hint_plan = super.callPackage ./ext/pg_hint_plan.nix { };
|
|
||||||
|
|
||||||
pg_ivm = super.callPackage ./ext/pg_ivm.nix { };
|
|
||||||
|
|
||||||
pg_rational = super.callPackage ./ext/pg_rational.nix { };
|
|
||||||
|
|
||||||
pg_repack = super.callPackage ./ext/pg_repack.nix { };
|
|
||||||
|
|
||||||
pg_similarity = super.callPackage ./ext/pg_similarity.nix { };
|
|
||||||
|
|
||||||
pgaudit = super.callPackage ./ext/pgaudit.nix { };
|
|
||||||
|
|
||||||
pgroonga = super.callPackage ./ext/pgroonga.nix { };
|
|
||||||
|
|
||||||
pgsodium = super.callPackage ./ext/pgsodium.nix { };
|
|
||||||
|
|
||||||
pgsql-http = super.callPackage ./ext/pgsql-http.nix { };
|
|
||||||
|
|
||||||
pgvecto-rs = super.callPackage ./ext/pgvecto-rs { };
|
|
||||||
|
|
||||||
pgvector = super.callPackage ./ext/pgvector.nix { };
|
|
||||||
|
|
||||||
plpgsql_check = super.callPackage ./ext/plpgsql_check.nix { };
|
|
||||||
|
|
||||||
plr = super.callPackage ./ext/plr.nix { };
|
|
||||||
|
|
||||||
plv8 = super.callPackage ./ext/plv8 { };
|
|
||||||
|
|
||||||
pgjwt = super.callPackage ./ext/pgjwt.nix { };
|
|
||||||
|
|
||||||
cstore_fdw = super.callPackage ./ext/cstore_fdw.nix { };
|
|
||||||
|
|
||||||
pg_hll = super.callPackage ./ext/pg_hll.nix { };
|
|
||||||
|
|
||||||
pg_cron = super.callPackage ./ext/pg_cron.nix { };
|
|
||||||
|
|
||||||
pg_topn = super.callPackage ./ext/pg_topn.nix { };
|
|
||||||
|
|
||||||
pg_net = super.callPackage ./ext/pg_net.nix { };
|
|
||||||
|
|
||||||
pgtap = super.callPackage ./ext/pgtap.nix { };
|
|
||||||
|
|
||||||
smlar = super.callPackage ./ext/smlar.nix { };
|
|
||||||
|
|
||||||
temporal_tables = super.callPackage ./ext/temporal_tables.nix { };
|
|
||||||
|
|
||||||
timescaledb = super.callPackage ./ext/timescaledb.nix { };
|
|
||||||
timescaledb-apache = super.callPackage ./ext/timescaledb.nix { enableUnfree = false; };
|
|
||||||
|
|
||||||
timescaledb_toolkit = super.callPackage ./ext/timescaledb_toolkit.nix { };
|
|
||||||
|
|
||||||
tsearch_extras = super.callPackage ./ext/tsearch_extras.nix { };
|
|
||||||
|
|
||||||
tds_fdw = super.callPackage ./ext/tds_fdw.nix { };
|
|
||||||
|
|
||||||
pgrouting = super.callPackage ./ext/pgrouting.nix { };
|
|
||||||
|
|
||||||
pg_partman = super.callPackage ./ext/pg_partman.nix { };
|
|
||||||
|
|
||||||
pg_relusage = super.callPackage ./ext/pg_relusage.nix { };
|
|
||||||
|
|
||||||
pg_safeupdate = super.callPackage ./ext/pg_safeupdate.nix { };
|
|
||||||
|
|
||||||
pg_squeeze = super.callPackage ./ext/pg_squeeze.nix { };
|
|
||||||
|
|
||||||
pg_uuidv7 = super.callPackage ./ext/pg_uuidv7.nix { };
|
|
||||||
|
|
||||||
promscale_extension = super.callPackage ./ext/promscale_extension.nix { };
|
|
||||||
|
|
||||||
repmgr = super.callPackage ./ext/repmgr.nix { };
|
|
||||||
|
|
||||||
rum = super.callPackage ./ext/rum.nix { };
|
|
||||||
|
|
||||||
tsja = super.callPackage ./ext/tsja.nix { };
|
|
||||||
|
|
||||||
wal2json = super.callPackage ./ext/wal2json.nix { };
|
|
||||||
}
|
|
|
@ -26743,8 +26743,8 @@ with pkgs;
|
||||||
postgresql_15_jit
|
postgresql_15_jit
|
||||||
postgresql_16_jit
|
postgresql_16_jit
|
||||||
;
|
;
|
||||||
postgresql = postgresql_15.override { this = postgresql; };
|
postgresql = postgresql_15;
|
||||||
postgresql_jit = postgresql_15_jit.override { this = postgresql_jit; };
|
postgresql_jit = postgresql_15_jit;
|
||||||
postgresqlPackages = recurseIntoAttrs postgresql.pkgs;
|
postgresqlPackages = recurseIntoAttrs postgresql.pkgs;
|
||||||
postgresqlJitPackages = recurseIntoAttrs postgresql_jit.pkgs;
|
postgresqlJitPackages = recurseIntoAttrs postgresql_jit.pkgs;
|
||||||
postgresql12Packages = recurseIntoAttrs postgresql_12.pkgs;
|
postgresql12Packages = recurseIntoAttrs postgresql_12.pkgs;
|
||||||
|
|
Loading…
Reference in a new issue