Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 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.24"; 97 psqlSchema = "9.3"; 98 sha256 = "1a8dnv16n2rxnbwhqw7c0kjpj3xqvkpwk50kvimj4d917cxaf542"; 99 }; 100 101 postgresql94 = common { 102 version = "9.4.19"; 103 psqlSchema = "9.4"; 104 sha256 = "12qn9h47rkn4k41gdbxkkvg0pff43k1113jmhc83f19adc1nnxq3"; 105 }; 106 107 postgresql95 = common { 108 version = "9.5.14"; 109 psqlSchema = "9.5"; 110 sha256 = "0k8s62h6qd9p3xlx315j5irniskqsnx1nz4ir5r1yhqp07mdab1y"; 111 }; 112 113 postgresql96 = common { 114 version = "9.6.10"; 115 psqlSchema = "9.6"; 116 sha256 = "09l4zqs74fqnazdsyln9x657mq3wsbgng9wpvq71yh26cv2sq5c6"; 117 }; 118 119 postgresql100 = common { 120 version = "10.5"; 121 psqlSchema = "10.0"; 122 sha256 = "04a07jkvc5s6zgh6jr78149kcjmsxclizsqabjw44ld4j5n633kc"; 123 }; 124 125}