2018-07-27 08:19:05 +02:00
|
|
|
{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, libxml2, makeWrapper, tzdata }:
|
2015-07-28 21:37:27 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2018-07-20 21:54:05 +02:00
|
|
|
common = { version, sha256, psqlSchema }:
|
2016-11-22 22:48:18 +01:00
|
|
|
let atLeast = lib.versionAtLeast version; in stdenv.mkDerivation (rec {
|
2015-07-28 21:37:27 +02:00
|
|
|
name = "postgresql-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://postgresql/source/v${version}/${name}.tar.bz2";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2017-09-27 21:48:39 +02:00
|
|
|
outputs = [ "out" "lib" "doc" "man" ];
|
2015-10-14 05:47:54 +02:00
|
|
|
setOutputFlags = false; # $out retains configureFlags :-/
|
2015-07-28 21:37:27 +02:00
|
|
|
|
|
|
|
buildInputs =
|
2018-07-27 08:19:05 +02:00
|
|
|
[ zlib readline openssl libxml2 makeWrapper ]
|
2015-07-28 21:37:27 +02:00
|
|
|
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
makeFlags = [ "world" ];
|
|
|
|
|
2018-07-31 05:23:17 +02:00
|
|
|
NIX_CFLAGS_COMPILE = [ "-I${libxml2.dev}/include/libxml2" ];
|
|
|
|
|
2018-08-19 09:07:00 +02:00
|
|
|
# Otherwise it retains a reference to compiler and fails; see #44767. TODO: better.
|
2018-08-20 10:07:27 +02:00
|
|
|
preConfigure = "CC=${stdenv.cc.targetPrefix}cc";
|
2018-08-19 09:07:00 +02:00
|
|
|
|
2015-10-14 05:47:54 +02:00
|
|
|
configureFlags = [
|
|
|
|
"--with-openssl"
|
2017-07-15 15:58:17 +02:00
|
|
|
"--with-libxml"
|
2015-10-14 05:47:54 +02:00
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--libdir=$(lib)/lib"
|
2018-08-11 20:06:13 +02:00
|
|
|
"--with-system-tzdata=${tzdata}/share/zoneinfo"
|
2018-08-02 22:22:42 +02:00
|
|
|
(if stdenv.isDarwin then "--with-uuid=e2fs" else "--with-ossp-uuid")
|
|
|
|
];
|
2015-07-28 21:37:27 +02:00
|
|
|
|
|
|
|
patches =
|
2016-11-22 22:48:18 +01:00
|
|
|
[ (if atLeast "9.4" then ./disable-resolve_symlinks-94.patch else ./disable-resolve_symlinks.patch)
|
|
|
|
(if atLeast "9.6" then ./less-is-more-96.patch else ./less-is-more.patch)
|
|
|
|
(if atLeast "9.6" then ./hardcode-pgxs-path-96.patch else ./hardcode-pgxs-path.patch)
|
2016-08-19 09:06:40 +02:00
|
|
|
./specify_pkglibdir_at_runtime.patch
|
2015-07-28 21:37:27 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
installTargets = [ "install-world" ];
|
|
|
|
|
|
|
|
LC_ALL = "C";
|
|
|
|
|
2016-05-15 02:37:10 +02:00
|
|
|
postConfigure =
|
2016-11-22 22:48:18 +01:00
|
|
|
let path = if atLeast "9.6" then "src/common/config_info.c" else "src/bin/pg_config/pg_config.c"; in
|
|
|
|
''
|
|
|
|
# Hardcode the path to pgxs so pg_config returns the path in $out
|
2017-09-27 21:48:39 +02:00
|
|
|
substituteInPlace "${path}" --replace HARDCODED_PGXS_PATH $out/lib
|
2016-11-22 22:48:18 +01:00
|
|
|
'';
|
2016-05-15 02:37:10 +02:00
|
|
|
|
2015-07-28 21:37:27 +02:00
|
|
|
postInstall =
|
|
|
|
''
|
2017-09-27 21:48:39 +02:00
|
|
|
moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
|
2015-12-02 10:03:23 +01:00
|
|
|
moveToOutput "lib/*.a" "$out"
|
|
|
|
moveToOutput "lib/libecpg*" "$out"
|
2015-10-14 05:47:54 +02:00
|
|
|
|
2017-09-27 21:48:39 +02:00
|
|
|
# Prevent a retained dependency on gcc-wrapper.
|
|
|
|
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv.cc}/bin/ld ld
|
|
|
|
|
2018-01-11 15:19:46 +01:00
|
|
|
if [ -z "''${dontDisableStatic:-}" ]; then
|
|
|
|
# Remove static libraries in case dynamic are available.
|
|
|
|
for i in $out/lib/*.a; do
|
|
|
|
name="$(basename "$i")"
|
|
|
|
if [ -e "$lib/lib/''${name%.a}.so" ] || [ -e "''${i%.a}.so" ]; then
|
|
|
|
rm "$i"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2015-07-28 21:37:27 +02:00
|
|
|
'';
|
|
|
|
|
2018-01-12 05:27:55 +01:00
|
|
|
postFixup = lib.optionalString (!stdenv.isDarwin && stdenv.hostPlatform.libc == "glibc")
|
2016-11-22 22:48:18 +01:00
|
|
|
''
|
|
|
|
# initdb needs access to "locale" command from glibc.
|
|
|
|
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
|
|
|
|
'';
|
|
|
|
|
2018-04-25 05:20:18 +02:00
|
|
|
doInstallCheck = false; # needs a running daemon?
|
|
|
|
|
2015-07-28 21:37:27 +02:00
|
|
|
disallowedReferences = [ stdenv.cc ];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit readline psqlSchema;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
2018-11-02 19:31:20 +01:00
|
|
|
homepage = https://www.postgresql.org;
|
2015-07-28 21:37:27 +02:00
|
|
|
description = "A powerful, open source object-relational database system";
|
2018-11-02 19:31:20 +01:00
|
|
|
license = licenses.postgresql;
|
|
|
|
maintainers = with maintainers; [ ocharles thoughtpolice ];
|
|
|
|
platforms = platforms.unix;
|
2015-07-28 21:37:27 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
2018-10-23 18:22:14 +02:00
|
|
|
postgresql_9_3 = common {
|
2018-08-16 21:51:25 +02:00
|
|
|
version = "9.3.24";
|
2015-07-28 21:37:27 +02:00
|
|
|
psqlSchema = "9.3";
|
2018-08-16 21:51:25 +02:00
|
|
|
sha256 = "1a8dnv16n2rxnbwhqw7c0kjpj3xqvkpwk50kvimj4d917cxaf542";
|
2015-07-28 21:37:27 +02:00
|
|
|
};
|
|
|
|
|
2018-10-23 18:22:14 +02:00
|
|
|
postgresql_9_4 = common {
|
2018-08-16 21:48:24 +02:00
|
|
|
version = "9.4.19";
|
2015-07-28 21:37:27 +02:00
|
|
|
psqlSchema = "9.4";
|
2018-08-16 21:48:24 +02:00
|
|
|
sha256 = "12qn9h47rkn4k41gdbxkkvg0pff43k1113jmhc83f19adc1nnxq3";
|
2015-07-28 21:37:27 +02:00
|
|
|
};
|
|
|
|
|
2018-10-23 18:22:14 +02:00
|
|
|
postgresql_9_5 = common {
|
2018-08-16 21:44:52 +02:00
|
|
|
version = "9.5.14";
|
2016-01-08 16:47:03 +01:00
|
|
|
psqlSchema = "9.5";
|
2018-08-16 21:44:52 +02:00
|
|
|
sha256 = "0k8s62h6qd9p3xlx315j5irniskqsnx1nz4ir5r1yhqp07mdab1y";
|
2016-01-08 16:47:03 +01:00
|
|
|
};
|
|
|
|
|
2018-10-23 18:22:14 +02:00
|
|
|
postgresql_9_6 = common {
|
2018-08-16 21:41:05 +02:00
|
|
|
version = "9.6.10";
|
2016-11-22 22:48:18 +01:00
|
|
|
psqlSchema = "9.6";
|
2018-08-16 21:41:05 +02:00
|
|
|
sha256 = "09l4zqs74fqnazdsyln9x657mq3wsbgng9wpvq71yh26cv2sq5c6";
|
2016-11-22 22:48:18 +01:00
|
|
|
};
|
2016-01-08 16:47:03 +01:00
|
|
|
|
2018-10-23 18:22:14 +02:00
|
|
|
postgresql_10 = common {
|
2018-08-16 21:36:17 +02:00
|
|
|
version = "10.5";
|
2017-10-07 00:50:44 +02:00
|
|
|
psqlSchema = "10.0";
|
2018-08-16 21:36:17 +02:00
|
|
|
sha256 = "04a07jkvc5s6zgh6jr78149kcjmsxclizsqabjw44ld4j5n633kc";
|
2017-10-07 00:50:44 +02:00
|
|
|
};
|
|
|
|
|
2018-10-18 15:52:29 +02:00
|
|
|
postgresql_11 = common {
|
|
|
|
version = "11.0";
|
|
|
|
psqlSchema = "11.0";
|
|
|
|
sha256 = "0szk9ssfych1wlpyqxz3z6dllg1l6m5labpii8c2r463s01vm6xz";
|
|
|
|
};
|
|
|
|
|
2015-07-28 21:37:27 +02:00
|
|
|
}
|