2017-07-15 14:58:17 +01:00
|
|
|
{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, libxml2, makeWrapper }:
|
2015-07-28 20:37:27 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2016-11-22 21:48:18 +00:00
|
|
|
common = { version, sha256, psqlSchema } @ args:
|
|
|
|
let atLeast = lib.versionAtLeast version; in stdenv.mkDerivation (rec {
|
2015-07-28 20:37:27 +01:00
|
|
|
name = "postgresql-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "mirror://postgresql/source/v${version}/${name}.tar.bz2";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2017-09-27 20:48:39 +01:00
|
|
|
outputs = [ "out" "lib" "doc" "man" ];
|
2015-10-14 04:47:54 +01:00
|
|
|
setOutputFlags = false; # $out retains configureFlags :-/
|
2015-07-28 20:37:27 +01:00
|
|
|
|
|
|
|
buildInputs =
|
2017-07-15 14:58:17 +01:00
|
|
|
[ zlib readline openssl libxml2 makeWrapper ]
|
2015-07-28 20:37:27 +01:00
|
|
|
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
makeFlags = [ "world" ];
|
|
|
|
|
2015-10-14 04:47:54 +01:00
|
|
|
configureFlags = [
|
|
|
|
"--with-openssl"
|
2017-07-15 14:58:17 +01:00
|
|
|
"--with-libxml"
|
2015-10-14 04:47:54 +01:00
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--libdir=$(lib)/lib"
|
|
|
|
]
|
2015-07-28 20:37:27 +01:00
|
|
|
++ lib.optional (stdenv.isDarwin) "--with-uuid=e2fs"
|
|
|
|
++ lib.optional (!stdenv.isDarwin) "--with-ossp-uuid";
|
|
|
|
|
|
|
|
patches =
|
2016-11-22 21:48:18 +00: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 08:06:40 +01:00
|
|
|
./specify_pkglibdir_at_runtime.patch
|
2015-07-28 20:37:27 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
installTargets = [ "install-world" ];
|
|
|
|
|
|
|
|
LC_ALL = "C";
|
|
|
|
|
2016-05-15 01:37:10 +01:00
|
|
|
postConfigure =
|
2016-11-22 21:48:18 +00: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 20:48:39 +01:00
|
|
|
substituteInPlace "${path}" --replace HARDCODED_PGXS_PATH $out/lib
|
2016-11-22 21:48:18 +00:00
|
|
|
'';
|
2016-05-15 01:37:10 +01:00
|
|
|
|
2015-07-28 20:37:27 +01:00
|
|
|
postInstall =
|
|
|
|
''
|
2017-09-27 20:48:39 +01:00
|
|
|
moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
|
2015-12-02 09:03:23 +00:00
|
|
|
moveToOutput "lib/*.a" "$out"
|
|
|
|
moveToOutput "lib/libecpg*" "$out"
|
2015-10-14 04:47:54 +01:00
|
|
|
|
2017-09-27 20:48:39 +01:00
|
|
|
# Prevent a retained dependency on gcc-wrapper.
|
|
|
|
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv.cc}/bin/ld ld
|
|
|
|
|
2018-01-11 14:19:46 +00: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 20:37:27 +01:00
|
|
|
'';
|
|
|
|
|
2016-11-24 08:56:12 +00:00
|
|
|
postFixup = lib.optionalString (!stdenv.isDarwin)
|
2016-11-22 21:48:18 +00:00
|
|
|
''
|
|
|
|
# initdb needs access to "locale" command from glibc.
|
|
|
|
wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin
|
|
|
|
'';
|
|
|
|
|
2015-07-28 20:37:27 +01:00
|
|
|
disallowedReferences = [ stdenv.cc ];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit readline psqlSchema;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
2017-08-22 19:50:04 +01:00
|
|
|
homepage = https://www.postgresql.org;
|
2015-07-28 20:37:27 +01:00
|
|
|
description = "A powerful, open source object-relational database system";
|
|
|
|
license = licenses.postgresql;
|
|
|
|
maintainers = [ maintainers.ocharles ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
postgresql93 = common {
|
2018-01-01 23:00:25 +00:00
|
|
|
version = "9.3.20";
|
2015-07-28 20:37:27 +01:00
|
|
|
psqlSchema = "9.3";
|
2018-01-01 23:00:25 +00:00
|
|
|
sha256 = "1jp6lac4b0q6hb28yrdsl0ymzn75gg59hvp5zasarf3mf3b8l4zb";
|
2015-07-28 20:37:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
postgresql94 = common {
|
2018-01-01 23:00:51 +00:00
|
|
|
version = "9.4.15";
|
2015-07-28 20:37:27 +01:00
|
|
|
psqlSchema = "9.4";
|
2018-01-01 23:00:51 +00:00
|
|
|
sha256 = "1i5c67gg4fj38hk07h6w6m4mqak84bhnblqsjbpiamg4x33v7gqj";
|
2015-07-28 20:37:27 +01:00
|
|
|
};
|
|
|
|
|
2016-01-08 15:47:03 +00:00
|
|
|
postgresql95 = common {
|
2018-01-01 23:01:29 +00:00
|
|
|
version = "9.5.10";
|
2016-01-08 15:47:03 +00:00
|
|
|
psqlSchema = "9.5";
|
2018-01-01 23:01:29 +00:00
|
|
|
sha256 = "10gjfn16bhzkmlqfsn384w49db0j39bg3n4majwxdpjd17g7lpcl";
|
2016-01-08 15:47:03 +00:00
|
|
|
};
|
|
|
|
|
2016-11-22 21:48:18 +00:00
|
|
|
postgresql96 = common {
|
2018-01-01 23:02:00 +00:00
|
|
|
version = "9.6.6";
|
2016-11-22 21:48:18 +00:00
|
|
|
psqlSchema = "9.6";
|
2018-01-01 23:02:00 +00:00
|
|
|
sha256 = "0m417h30s18rwa7yzkqqcdb22ifpcda2fpg2cyx8bxvjp3ydz71r";
|
2016-11-22 21:48:18 +00:00
|
|
|
};
|
2016-01-08 15:47:03 +00:00
|
|
|
|
2017-10-06 23:50:44 +01:00
|
|
|
postgresql100 = common {
|
2018-01-01 23:02:28 +00:00
|
|
|
version = "10.1";
|
2017-10-06 23:50:44 +01:00
|
|
|
psqlSchema = "10.0";
|
2018-01-01 23:02:28 +00:00
|
|
|
sha256 = "04z7lm4h94625vbncwv98svycqr942n3q47ailqaczkszqjlxjrw";
|
2017-10-06 23:50:44 +01:00
|
|
|
};
|
|
|
|
|
2015-07-28 20:37:27 +01:00
|
|
|
}
|