3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/servers/sql/postgresql/default.nix

117 lines
3.3 KiB
Nix
Raw Normal View History

{ 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;
};
outputs = [ "out" "dev" "lib" "doc" "man" ];
setOutputFlags = false; # $out retains configureFlags :-/
2015-07-28 20:37:27 +01:00
buildInputs =
[ zlib readline openssl libxml2 makeWrapper ]
2015-07-28 20:37:27 +01:00
++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ];
enableParallelBuilding = true;
makeFlags = [ "world" ];
configureFlags = [
"--with-openssl"
"--with-libxml"
"--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)
./specify_pkglibdir_at_runtime.patch
2015-07-28 20:37:27 +01:00
];
installTargets = [ "install-world" ];
LC_ALL = "C";
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 18:19:14 +01:00
substituteInPlace "${path}" --replace HARDCODED_PGXS_PATH $dev/lib
2016-11-22 21:48:18 +00:00
'';
2015-07-28 20:37:27 +01:00
postInstall =
''
moveToOutput "bin/pg_config" "$dev"
moveToOutput "lib/pgxs" "$dev" # looks strange, but not deleting it
moveToOutput "lib/*.a" "$out"
moveToOutput "lib/libecpg*" "$out"
# 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 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; {
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;
hydraPlatforms = platforms.linux;
};
});
in {
postgresql93 = common {
2017-09-05 16:47:07 +01:00
version = "9.3.19";
2015-07-28 20:37:27 +01:00
psqlSchema = "9.3";
2017-09-05 16:47:07 +01:00
sha256 = "1d9gmi1psg4aa6h6ylvsrdm5jnnb7p36pn4h2qrvl9z9v4n8g7pv";
2015-07-28 20:37:27 +01:00
};
postgresql94 = common {
2017-09-05 16:47:28 +01:00
version = "9.4.14";
2015-07-28 20:37:27 +01:00
psqlSchema = "9.4";
2017-09-05 16:47:28 +01:00
sha256 = "0szc0navrcjnpyafw2sai8cmwr3znsy0w6031lv7n1ab20xg4zcf";
2015-07-28 20:37:27 +01:00
};
postgresql95 = common {
2017-09-05 16:47:43 +01:00
version = "9.5.9";
psqlSchema = "9.5";
2017-09-05 16:47:43 +01:00
sha256 = "1m6d4y3m3ir20dzl6q3s3yvmr0a7hq3si2v1hg5hanmbck3db379";
};
2016-11-22 21:48:18 +00:00
postgresql96 = common {
2017-09-05 16:47:57 +01:00
version = "9.6.5";
2016-11-22 21:48:18 +00:00
psqlSchema = "9.6";
2017-09-05 16:47:57 +01:00
sha256 = "0k3ls2x182jz6djjiqj9kycddabdl2gk1y1ajq1vipnxwfki5nh6";
2016-11-22 21:48:18 +00:00
};
2015-07-28 20:37:27 +01:00
}