diff options
Diffstat (limited to 'pkgs/servers/sql')
24 files changed, 564 insertions, 638 deletions
diff --git a/pkgs/servers/sql/cockroachdb/default.nix b/pkgs/servers/sql/cockroachdb/default.nix deleted file mode 100644 index 19a128dfc003..000000000000 --- a/pkgs/servers/sql/cockroachdb/default.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ lib, stdenv, buildGoPackage, fetchurl -, cmake, xz, which, autoconf -, ncurses6, libedit, libunwind -, installShellFiles -, removeReferencesTo, go -}: - -let - darwinDeps = [ libunwind libedit ]; - linuxDeps = [ ncurses6 ]; - - buildInputs = if stdenv.isDarwin then darwinDeps else linuxDeps; - nativeBuildInputs = [ installShellFiles cmake xz which autoconf ]; - -in -buildGoPackage rec { - pname = "cockroach"; - version = "20.1.8"; - - goPackagePath = "github.com/cockroachdb/cockroach"; - - src = fetchurl { - url = "https://binaries.cockroachdb.com/cockroach-v${version}.src.tgz"; - sha256 = "0mm3hfr778c7djza8gr1clwa8wca4d3ldh9hlg80avw4x664y5zi"; - }; - - env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [ "-Wno-error=deprecated-copy" "-Wno-error=redundant-move" "-Wno-error=pessimizing-move" ]); - - inherit nativeBuildInputs buildInputs; - - buildPhase = '' - runHook preBuild - cd $NIX_BUILD_TOP/go/src/${goPackagePath} - patchShebangs . - make buildoss - cd src/${goPackagePath} - for asset in man autocomplete; do - ./cockroachoss gen $asset - done - runHook postBuild - ''; - - installPhase = '' - runHook preInstall - - install -D cockroachoss $out/bin/cockroach - installShellCompletion cockroach.bash - - mkdir -p $man/share/man - cp -r man $man/share/man - - runHook postInstall - ''; - - outputs = [ "out" "man" ]; - - # fails with `GOFLAGS=-trimpath` - allowGoReference = true; - preFixup = '' - find $out -type f -exec ${removeReferencesTo}/bin/remove-references-to -t ${go} '{}' + - ''; - - meta = with lib; { - homepage = "https://www.cockroachlabs.com"; - description = "A scalable, survivable, strongly-consistent SQL database"; - license = licenses.bsl11; - platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; - maintainers = with maintainers; [ rushmorem thoughtpolice ]; - }; -} diff --git a/pkgs/servers/sql/dolt/default.nix b/pkgs/servers/sql/dolt/default.nix index ee3b30bd0363..bb6687c20473 100644 --- a/pkgs/servers/sql/dolt/default.nix +++ b/pkgs/servers/sql/dolt/default.nix @@ -2,23 +2,24 @@ buildGoModule rec { pname = "dolt"; - version = "1.35.3"; + version = "1.35.4"; src = fetchFromGitHub { owner = "dolthub"; repo = "dolt"; rev = "v${version}"; - sha256 = "sha256-p4hScXdIDa3zAHltUMhg61YyfpdFWZaJ8LAdQi8OZv8="; + sha256 = "sha256-9EEqwS7IKlRfE5bwxjScDX7KMCTpmbxixAznRhbaOE0="; }; modRoot = "./go"; subPackages = [ "cmd/dolt" ]; - vendorHash = "sha256-1fH9JrWi38jtPjaN2lEplCkiLdYa4g6FsdcB8ZQqVD4="; + vendorHash = "sha256-TXx+YmXsAwh2J+nHpff0oHatI6G2QY2QZmMMcHAG6Lc="; proxyVendor = true; doCheck = false; meta = with lib; { description = "Relational database with version control and CLI a-la Git"; + mainProgram = "dolt"; homepage = "https://github.com/dolthub/dolt"; license = licenses.asl20; maintainers = with maintainers; [ danbst ]; diff --git a/pkgs/servers/sql/mariadb/galera/default.nix b/pkgs/servers/sql/mariadb/galera/default.nix index f934d6a00822..0898c6a3bfc4 100644 --- a/pkgs/servers/sql/mariadb/galera/default.nix +++ b/pkgs/servers/sql/mariadb/galera/default.nix @@ -36,6 +36,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Galera 3 wsrep provider library"; + mainProgram = "garbd"; homepage = "https://galeracluster.com/"; license = licenses.lgpl2Only; maintainers = with maintainers; [ izorkin ] ++ teams.helsinki-systems.members; diff --git a/pkgs/servers/sql/postgresql/12.nix b/pkgs/servers/sql/postgresql/12.nix new file mode 100644 index 000000000000..9e0388be0451 --- /dev/null +++ b/pkgs/servers/sql/postgresql/12.nix @@ -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="; + }; + }; +} diff --git a/pkgs/servers/sql/postgresql/13.nix b/pkgs/servers/sql/postgresql/13.nix new file mode 100644 index 000000000000..a4870812acdb --- /dev/null +++ b/pkgs/servers/sql/postgresql/13.nix @@ -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="; + }; + }; +} diff --git a/pkgs/servers/sql/postgresql/14.nix b/pkgs/servers/sql/postgresql/14.nix new file mode 100644 index 000000000000..2de876cf4ad6 --- /dev/null +++ b/pkgs/servers/sql/postgresql/14.nix @@ -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="; + }; + }; +} diff --git a/pkgs/servers/sql/postgresql/15.nix b/pkgs/servers/sql/postgresql/15.nix new file mode 100644 index 000000000000..f633dc975085 --- /dev/null +++ b/pkgs/servers/sql/postgresql/15.nix @@ -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="; + }; + }; +} diff --git a/pkgs/servers/sql/postgresql/16.nix b/pkgs/servers/sql/postgresql/16.nix new file mode 100644 index 000000000000..6a6420643b31 --- /dev/null +++ b/pkgs/servers/sql/postgresql/16.nix @@ -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="; + }; + }; +} diff --git a/pkgs/servers/sql/postgresql/default.nix b/pkgs/servers/sql/postgresql/default.nix index 700f0ad99bd1..d11a2d06b2d2 100644 --- a/pkgs/servers/sql/postgresql/default.nix +++ b/pkgs/servers/sql/postgresql/default.nix @@ -1,412 +1,24 @@ +self: let + versions = { + postgresql_12 = ./12.nix; + postgresql_13 = ./13.nix; + postgresql_14 = ./14.nix; + postgresql_15 = ./15.nix; + postgresql_16 = ./16.nix; + }; - 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. - , 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" ]; - - 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 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"; - }) - - ] ++ lib.optionals stdenv'.hostPlatform.isMusl ( + mkAttributes = jitSupport: + self.lib.mapAttrs' (version: path: let - self = { - "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}"); + attrName = if jitSupport then "${version}_jit" else 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; - }; - }; + self.lib.nameValuePair attrName (import path { + inherit jitSupport self; + thisAttr = attrName; + }) + ) versions; -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 +in +# variations without and with JIT +(mkAttributes false) // (mkAttributes true) diff --git a/pkgs/servers/sql/postgresql/ext/anonymizer.nix b/pkgs/servers/sql/postgresql/ext/anonymizer.nix new file mode 100644 index 000000000000..4bb5aa544440 --- /dev/null +++ b/pkgs/servers/sql/postgresql/ext/anonymizer.nix @@ -0,0 +1,32 @@ +{ lib, stdenv, pg-dump-anon, postgresql, runtimeShell, jitSupport, llvm }: + +stdenv.mkDerivation (finalAttrs: { + pname = "postgresql_anonymizer"; + + inherit (pg-dump-anon) version src passthru; + + buildInputs = [ postgresql ]; + nativeBuildInputs = [ postgresql ] ++ lib.optional jitSupport llvm; + + strictDeps = true; + + makeFlags = [ + "BINDIR=${placeholder "out"}/bin" + "datadir=${placeholder "out"}/share/postgresql" + "pkglibdir=${placeholder "out"}/lib" + "DESTDIR=" + ]; + + postInstall = '' + cat >$out/bin/pg_dump_anon.sh <<'EOF' + #!${runtimeShell} + echo "This script is deprecated by upstream. To use the new script," + echo "please install pkgs.pg-dump-anon." + exit 1 + EOF + ''; + + meta = lib.getAttrs [ "homepage" "maintainers" "license" ] pg-dump-anon.meta // { + description = "Extension to mask or replace personally identifiable information (PII) or commercially sensitive data from a PostgreSQL database"; + }; +}) diff --git a/pkgs/servers/sql/postgresql/ext/default.nix b/pkgs/servers/sql/postgresql/ext/default.nix new file mode 100644 index 000000000000..b6181da6cf02 --- /dev/null +++ b/pkgs/servers/sql/postgresql/ext/default.nix @@ -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 { }; +} diff --git a/pkgs/servers/sql/postgresql/ext/pg_auto_failover.nix b/pkgs/servers/sql/postgresql/ext/pg_auto_failover.nix index ad3c6895b2ae..7a1741b70490 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_auto_failover.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_auto_failover.nix @@ -22,6 +22,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "PostgreSQL extension and service for automated failover and high-availability"; + mainProgram = "pg_autoctl"; homepage = "https://github.com/citusdata/pg_auto_failover"; changelog = "https://github.com/citusdata/pg_auto_failover/blob/v${version}/CHANGELOG.md"; maintainers = [ maintainers.marsam ]; diff --git a/pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix b/pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix index 7abeba5adda1..9bbde3b195da 100644 --- a/pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix +++ b/pkgs/servers/sql/postgresql/ext/pg_uuidv7.nix @@ -6,7 +6,7 @@ stdenv.mkDerivation rec { pname = "pg_uuidv7"; - version = "1.4.1"; + version = "1.5.0"; buildInputs = [ postgresql ]; @@ -14,7 +14,7 @@ stdenv.mkDerivation rec { owner = "fboulnois"; repo = "pg_uuidv7"; rev = "v${version}"; - hash = "sha256-1qEsDCcULceMqvR3DIC5rOfpzn2PYbFGq0H8p2+9GR4="; + hash = "sha256-oVyRtjl3KsD3j96qvQb8bFLMhoWO81OudOL4wVXrjzI="; }; installPhase = '' diff --git a/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix b/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix index 23d4499029ea..d6a4f24bf5e6 100644 --- a/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix +++ b/pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix @@ -1,6 +1,6 @@ { lib , buildPgrxExtension -, cargo-pgrx +, cargo-pgrx_0_11_2 , clang_16 , fetchCrate , fetchFromGitHub @@ -23,27 +23,11 @@ let bindgenHook = rustPlatform.bindgenHook.override { inherit clang; }; }; +in +(buildPgrxExtension.override { # Upstream only works with a fixed version of cargo-pgrx for each release, # so we're pinning it here to avoid future incompatibility. # See https://docs.pgvecto.rs/developers/development.html#environment, step 6 - cargo-pgrx_0_11_2 = cargo-pgrx.overrideAttrs (old: rec { - pname = "cargo-pgrx"; - version = "0.11.2"; - - src = fetchCrate { - pname = "cargo-pgrx"; - inherit version; - hash = "sha256-8NlpMDFaltTIA8G4JioYm8LaPJ2RGKH5o6sd6lBHmmM="; - }; - - cargoDeps = old.cargoDeps.overrideAttrs (_: { - inherit src; - outputHash = "sha256-qTb3JV3u42EilaK2jP9oa5D09mkuHyRbGGRs9Rg4TzI="; - }); - }); - -in -(buildPgrxExtension.override { cargo-pgrx = cargo-pgrx_0_11_2; rustPlatform = rustPlatform'; }) rec { diff --git a/pkgs/servers/sql/postgresql/ext/pgvector.nix b/pkgs/servers/sql/postgresql/ext/pgvector.nix index e30e59d9da93..1dfda512e1d4 100644 --- a/pkgs/servers/sql/postgresql/ext/pgvector.nix +++ b/pkgs/servers/sql/postgresql/ext/pgvector.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation rec { pname = "pgvector"; - version = "0.6.1"; + version = "0.6.2"; src = fetchFromGitHub { owner = "pgvector"; repo = "pgvector"; rev = "v${version}"; - hash = "sha256-NS9iNgrVnoqmAIXd4sJFnPISQvYYl8YQ84bnLjpChx4="; + hash = "sha256-r+TpFJg6WrMn0L2B7RpmSRvw3XxpHzMRtpFWDCzLvgs="; }; buildInputs = [ postgresql ]; diff --git a/pkgs/servers/sql/postgresql/ext/plpgsql_check.nix b/pkgs/servers/sql/postgresql/ext/plpgsql_check.nix index c2c974a8d872..ac6f0e948722 100644 --- a/pkgs/servers/sql/postgresql/ext/plpgsql_check.nix +++ b/pkgs/servers/sql/postgresql/ext/plpgsql_check.nix @@ -2,13 +2,13 @@ stdenv.mkDerivation rec { pname = "plpgsql-check"; - version = "2.7.3"; + version = "2.7.4"; src = fetchFromGitHub { owner = "okbob"; repo = "plpgsql_check"; rev = "v${version}"; - hash = "sha256-VFM8SplBGlJd2RfUgS0FLH+xkyLOCVY2jaK6mn878CQ="; + hash = "sha256-qPYH6i8XJZVH+5zM/gozf+0Kts/Tzv6fRWkayGEe+5U="; }; buildInputs = [ postgresql ]; diff --git a/pkgs/servers/sql/postgresql/ext/plv8/default.nix b/pkgs/servers/sql/postgresql/ext/plv8/default.nix index 241aa610c8f9..fa2f1b7ad2d8 100644 --- a/pkgs/servers/sql/postgresql/ext/plv8/default.nix +++ b/pkgs/servers/sql/postgresql/ext/plv8/default.nix @@ -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; }; }) diff --git a/pkgs/servers/sql/postgresql/ext/postgis.nix b/pkgs/servers/sql/postgresql/ext/postgis.nix index 87333fe97504..523bd154f6e5 100644 --- a/pkgs/servers/sql/postgresql/ext/postgis.nix +++ b/pkgs/servers/sql/postgresql/ext/postgis.nix @@ -13,6 +13,8 @@ , libiconv , pcre2 , nixosTests +, jitSupport +, llvm }: let @@ -31,13 +33,11 @@ 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 - NIX_LDFLAGS = "-L${lib.getLib json_c}/lib" - # Work around https://github.com/NixOS/nixpkgs/issues/166205. - + lib.optionalString (stdenv.cc.isClang && stdenv.cc.libcxx != null) " -l${stdenv.cc.libcxx.cxxabi.libName}"; + env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib"; preConfigure = '' diff --git a/pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix b/pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix index 77dd41db7f6d..96bff3fe20b3 100644 --- a/pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix +++ b/pkgs/servers/sql/postgresql/ext/timescaledb_toolkit.nix @@ -3,31 +3,12 @@ , buildPgrxExtension , postgresql , nixosTests -, cargo-pgrx +, cargo-pgrx_0_10_2 , fetchCrate , nix-update-script , stdenv }: -let - cargo-pgrx_0_10_2 = cargo-pgrx.overrideAttrs (old: rec { - name = "cargo-pgrx-${version}"; - version = "0.10.2"; - - src = fetchCrate { - pname = "cargo-pgrx"; - inherit version; - hash = "sha256-FqjfbJmSy5UCpPPPk4bkEyvQCnaH9zYtkI7txgIn+ls="; - }; - - cargoDeps = old.cargoDeps.overrideAttrs (_: { - inherit src; - outputHash = "sha256-XyI3RaPI3Edm/tCP2xoZemib2d2n2cAhobgk9Oafg6s="; - }); - }); - -in - (buildPgrxExtension.override { cargo-pgrx = cargo-pgrx_0_10_2; }) rec { inherit postgresql; diff --git a/pkgs/servers/sql/postgresql/generic.nix b/pkgs/servers/sql/postgresql/generic.nix new file mode 100644 index 000000000000..5d93cf9aa31b --- /dev/null +++ b/pkgs/servers/sql/postgresql/generic.nix @@ -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) diff --git a/pkgs/servers/sql/postgresql/packages.nix b/pkgs/servers/sql/postgresql/packages.nix deleted file mode 100644 index 9cc83118c526..000000000000 --- a/pkgs/servers/sql/postgresql/packages.nix +++ /dev/null @@ -1,105 +0,0 @@ -self: super: { - - age = super.callPackage ./ext/age.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 { }; -} diff --git a/pkgs/servers/sql/postgresql/locale-binary-path.patch b/pkgs/servers/sql/postgresql/patches/locale-binary-path.patch index 08e90bce750c..08e90bce750c 100644 --- a/pkgs/servers/sql/postgresql/locale-binary-path.patch +++ b/pkgs/servers/sql/postgresql/patches/locale-binary-path.patch diff --git a/pkgs/servers/sql/proxysql/default.nix b/pkgs/servers/sql/proxysql/default.nix index 891ee8e53134..e0a6f23a4631 100644 --- a/pkgs/servers/sql/proxysql/default.nix +++ b/pkgs/servers/sql/proxysql/default.nix @@ -166,6 +166,7 @@ stdenv.mkDerivation (finalAttrs: { meta = with lib; { broken = stdenv.isDarwin; description = "High-performance MySQL proxy"; + mainProgram = "proxysql"; homepage = "https://proxysql.com/"; license = with licenses; [ gpl3Only ]; maintainers = teams.helsinki-systems.members; diff --git a/pkgs/servers/sql/rqlite/default.nix b/pkgs/servers/sql/rqlite/default.nix index d8bcadbb9df9..3f06ae1e43da 100644 --- a/pkgs/servers/sql/rqlite/default.nix +++ b/pkgs/servers/sql/rqlite/default.nix @@ -5,16 +5,16 @@ buildGoModule rec { pname = "rqlite"; - version = "8.22.1"; + version = "8.23.0"; src = fetchFromGitHub { owner = "rqlite"; repo = pname; rev = "v${version}"; - sha256 = "sha256-g5W+rHD4gUS82E+wFLQ3VTSwIWQUogwTutwPTtf+IdM="; + sha256 = "sha256-n4ALjayvcOR+VcpKPRh6WswAEEdlYyxhYyfPRje98Rs="; }; - vendorHash = "sha256-onR4n6ok6y9APRwGjBoMISbidGDVw19D48TkogRp1uM="; + vendorHash = "sha256-UYO5asCX+KpESAT1ws7O91QaOJ8zPbd06JzHexBiWj0="; subPackages = [ "cmd/rqlite" "cmd/rqlited" "cmd/rqbench" ]; |