at 18.03-beta 125 lines 3.7 kB view raw
1{ lib, stdenv, glibc, fetchurl, zlib, readline, libossp_uuid, openssl, libxml2, makeWrapper }: 2 3let 4 5 common = { version, sha256, psqlSchema } @ args: 6 let atLeast = lib.versionAtLeast version; in stdenv.mkDerivation (rec { 7 name = "postgresql-${version}"; 8 9 src = fetchurl { 10 url = "mirror://postgresql/source/v${version}/${name}.tar.bz2"; 11 inherit sha256; 12 }; 13 14 outputs = [ "out" "lib" "doc" "man" ]; 15 setOutputFlags = false; # $out retains configureFlags :-/ 16 17 buildInputs = 18 [ zlib readline openssl libxml2 makeWrapper ] 19 ++ lib.optionals (!stdenv.isDarwin) [ libossp_uuid ]; 20 21 enableParallelBuilding = true; 22 23 makeFlags = [ "world" ]; 24 25 configureFlags = [ 26 "--with-openssl" 27 "--with-libxml" 28 "--sysconfdir=/etc" 29 "--libdir=$(lib)/lib" 30 ] 31 ++ lib.optional (stdenv.isDarwin) "--with-uuid=e2fs" 32 ++ lib.optional (!stdenv.isDarwin) "--with-ossp-uuid"; 33 34 patches = 35 [ (if atLeast "9.4" then ./disable-resolve_symlinks-94.patch else ./disable-resolve_symlinks.patch) 36 (if atLeast "9.6" then ./less-is-more-96.patch else ./less-is-more.patch) 37 (if atLeast "9.6" then ./hardcode-pgxs-path-96.patch else ./hardcode-pgxs-path.patch) 38 ./specify_pkglibdir_at_runtime.patch 39 ]; 40 41 installTargets = [ "install-world" ]; 42 43 LC_ALL = "C"; 44 45 postConfigure = 46 let path = if atLeast "9.6" then "src/common/config_info.c" else "src/bin/pg_config/pg_config.c"; in 47 '' 48 # Hardcode the path to pgxs so pg_config returns the path in $out 49 substituteInPlace "${path}" --replace HARDCODED_PGXS_PATH $out/lib 50 ''; 51 52 postInstall = 53 '' 54 moveToOutput "lib/pgxs" "$out" # looks strange, but not deleting it 55 moveToOutput "lib/*.a" "$out" 56 moveToOutput "lib/libecpg*" "$out" 57 58 # Prevent a retained dependency on gcc-wrapper. 59 substituteInPlace "$out/lib/pgxs/src/Makefile.global" --replace ${stdenv.cc}/bin/ld ld 60 61 if [ -z "''${dontDisableStatic:-}" ]; then 62 # Remove static libraries in case dynamic are available. 63 for i in $out/lib/*.a; do 64 name="$(basename "$i")" 65 if [ -e "$lib/lib/''${name%.a}.so" ] || [ -e "''${i%.a}.so" ]; then 66 rm "$i" 67 fi 68 done 69 fi 70 ''; 71 72 postFixup = lib.optionalString (!stdenv.isDarwin && stdenv.hostPlatform.libc == "glibc") 73 '' 74 # initdb needs access to "locale" command from glibc. 75 wrapProgram $out/bin/initdb --prefix PATH ":" ${glibc.bin}/bin 76 ''; 77 78 disallowedReferences = [ stdenv.cc ]; 79 80 passthru = { 81 inherit readline psqlSchema; 82 }; 83 84 meta = with lib; { 85 homepage = https://www.postgresql.org; 86 description = "A powerful, open source object-relational database system"; 87 license = licenses.postgresql; 88 maintainers = [ maintainers.ocharles ]; 89 platforms = platforms.unix; 90 }; 91 }); 92 93in { 94 95 postgresql93 = common { 96 version = "9.3.20"; 97 psqlSchema = "9.3"; 98 sha256 = "1jp6lac4b0q6hb28yrdsl0ymzn75gg59hvp5zasarf3mf3b8l4zb"; 99 }; 100 101 postgresql94 = common { 102 version = "9.4.15"; 103 psqlSchema = "9.4"; 104 sha256 = "1i5c67gg4fj38hk07h6w6m4mqak84bhnblqsjbpiamg4x33v7gqj"; 105 }; 106 107 postgresql95 = common { 108 version = "9.5.10"; 109 psqlSchema = "9.5"; 110 sha256 = "10gjfn16bhzkmlqfsn384w49db0j39bg3n4majwxdpjd17g7lpcl"; 111 }; 112 113 postgresql96 = common { 114 version = "9.6.6"; 115 psqlSchema = "9.6"; 116 sha256 = "0m417h30s18rwa7yzkqqcdb22ifpcda2fpg2cyx8bxvjp3ydz71r"; 117 }; 118 119 postgresql100 = common { 120 version = "10.1"; 121 psqlSchema = "10.0"; 122 sha256 = "04z7lm4h94625vbncwv98svycqr942n3q47ailqaczkszqjlxjrw"; 123 }; 124 125}