2016-11-22 22:48:18 +01:00
|
|
|
{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, makeWrapper }:
|
2015-07-28 21:37:27 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2016-11-22 22:48:18 +01:00
|
|
|
common = { version, sha256, psqlSchema } @ args:
|
|
|
|
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-05-20 07:58:42 +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 =
|
2016-11-22 22:48:18 +01:00
|
|
|
[ zlib readline openssl makeWrapper ]
|
2015-07-28 21:37:27 +02:00
|
|
|
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
makeFlags = [ "world" ];
|
|
|
|
|
2015-10-14 05:47:54 +02:00
|
|
|
configureFlags = [
|
|
|
|
"--with-openssl"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--libdir=$(lib)/lib"
|
|
|
|
]
|
2015-07-28 21:37:27 +02:00
|
|
|
++ lib.optional (stdenv.isDarwin) "--with-uuid=e2fs"
|
|
|
|
++ lib.optional (!stdenv.isDarwin) "--with-ossp-uuid";
|
|
|
|
|
|
|
|
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
|
|
|
|
substituteInPlace "${path}" --replace HARDCODED_PGXS_PATH $out/lib
|
|
|
|
'';
|
2016-05-15 02:37:10 +02:00
|
|
|
|
2015-07-28 21:37:27 +02:00
|
|
|
postInstall =
|
|
|
|
''
|
2015-12-02 10:03:23 +01:00
|
|
|
moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it
|
|
|
|
moveToOutput "lib/*.a" "$out"
|
|
|
|
moveToOutput "lib/libecpg*" "$out"
|
2015-10-14 05:47:54 +02:00
|
|
|
|
2015-07-28 21:37:27 +02:00
|
|
|
# Prevent a retained dependency on gcc-wrapper.
|
2015-10-14 05:47:54 +02:00
|
|
|
substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv.cc}/bin/ld ld
|
2017-02-11 00:40:13 +01:00
|
|
|
|
|
|
|
# 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
|
2015-07-28 21:37:27 +02:00
|
|
|
'';
|
|
|
|
|
2016-11-24 09:56:12 +01:00
|
|
|
postFixup = lib.optionalString (!stdenv.isDarwin)
|
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
|
|
|
|
'';
|
|
|
|
|
2015-07-28 21:37:27 +02:00
|
|
|
disallowedReferences = [ stdenv.cc ];
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
inherit readline psqlSchema;
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = http://www.postgresql.org/;
|
|
|
|
description = "A powerful, open source object-relational database system";
|
|
|
|
license = licenses.postgresql;
|
|
|
|
maintainers = [ maintainers.ocharles ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
hydraPlatforms = platforms.linux;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
|
|
|
postgresql91 = common {
|
2016-11-23 00:13:26 +01:00
|
|
|
version = "9.1.24";
|
2015-07-28 21:37:27 +02:00
|
|
|
psqlSchema = "9.1";
|
2016-11-23 00:13:26 +01:00
|
|
|
sha256 = "1lz5ibvgz6cxprxlnd7a8iwv387idr7k53bdsvy4bw9ayglq83fy";
|
2015-07-28 21:37:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
postgresql92 = common {
|
2017-02-09 22:29:03 +01:00
|
|
|
version = "9.2.20";
|
2015-07-28 21:37:27 +02:00
|
|
|
psqlSchema = "9.2";
|
2017-02-09 22:29:03 +01:00
|
|
|
sha256 = "09lgvl996py3mciybnlv0hycfwfxr41n0wksb2jvxjh0hjpbv2hb";
|
2015-07-28 21:37:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
postgresql93 = common {
|
2017-02-09 22:29:03 +01:00
|
|
|
version = "9.3.16";
|
2015-07-28 21:37:27 +02:00
|
|
|
psqlSchema = "9.3";
|
2017-02-09 22:29:03 +01:00
|
|
|
sha256 = "0wv8qsi0amdhcl1qvkvas3lm37w6zsi818f5fxm6n0ngr155wpw4";
|
2015-07-28 21:37:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
postgresql94 = common {
|
2017-02-09 22:29:03 +01:00
|
|
|
version = "9.4.11";
|
2015-07-28 21:37:27 +02:00
|
|
|
psqlSchema = "9.4";
|
2017-02-09 22:29:03 +01:00
|
|
|
sha256 = "08wxrk8wdhnz0756dsa8jkj0pqanjfpw7w715lyv10618p853sz3";
|
2015-07-28 21:37:27 +02:00
|
|
|
};
|
|
|
|
|
2016-01-08 16:47:03 +01:00
|
|
|
postgresql95 = common {
|
2017-02-09 22:29:03 +01:00
|
|
|
version = "9.5.6";
|
2016-01-08 16:47:03 +01:00
|
|
|
psqlSchema = "9.5";
|
2017-02-09 22:29:03 +01:00
|
|
|
sha256 = "0bz1b9r249ffjfvldaiah2g78ccwq30ddh8hdvlq61z26inmz7mv";
|
2016-01-08 16:47:03 +01:00
|
|
|
};
|
|
|
|
|
2016-11-22 22:48:18 +01:00
|
|
|
postgresql96 = common {
|
2017-02-09 22:29:03 +01:00
|
|
|
version = "9.6.2";
|
2016-11-22 22:48:18 +01:00
|
|
|
psqlSchema = "9.6";
|
2017-02-09 22:29:03 +01:00
|
|
|
sha256 = "1jahzqqw5inyvmacic2ihhj5f8z50lapci2fwws91h719ccbb1q1";
|
2016-11-22 22:48:18 +01:00
|
|
|
};
|
2016-01-08 16:47:03 +01:00
|
|
|
|
2015-07-28 21:37:27 +02:00
|
|
|
}
|