Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 87 lines 2.7 kB view raw
1{ fetchurl 2, lib, stdenv 3, perl 4, libxml2 5, postgresql 6, geos 7, proj 8, gdalMinimal 9, json_c 10, pkg-config 11, file 12, protobufc 13, libiconv 14, pcre2 15, nixosTests 16, jitSupport 17, llvm 18}: 19 20let 21 gdal = gdalMinimal; 22in 23stdenv.mkDerivation rec { 24 pname = "postgis"; 25 version = "3.4.2"; 26 27 outputs = [ "out" "doc" ]; 28 29 src = fetchurl { 30 url = "https://download.osgeo.org/postgis/source/postgis-${version}.tar.gz"; 31 sha256 = "sha256-yMh0wAukqYSocDCva/lUSCFQIGCtRz1clvHU0INcWJI="; 32 }; 33 34 buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2.dev ] 35 ++ lib.optional stdenv.isDarwin libiconv; 36 nativeBuildInputs = [ perl pkg-config ] ++ lib.optional jitSupport llvm; 37 dontDisableStatic = true; 38 39 # postgis config directory assumes /include /lib from the same root for json-c library 40 env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib"; 41 42 43 preConfigure = '' 44 sed -i 's@/usr/bin/file@${file}/bin/file@' configure 45 configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --docdir=$doc/share/doc/${pname} --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev} --disable-extension-upgrades-install" 46 47 makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin docdir=$doc/share/doc/${pname}" 48 ''; 49 postConfigure = '' 50 sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ; 51 s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g 52 " \ 53 "raster/loader/Makefile"; 54 sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g 55 " \ 56 "raster/scripts/python/Makefile"; 57 mkdir -p $out/bin 58 59 # postgis' build system assumes it is being installed to the same place as postgresql, and looks 60 # for the postgres binary relative to $PREFIX. We gently support this system using an illusion. 61 ln -s ${postgresql}/bin/postgres $out/bin/postgres 62 ''; 63 64 # create aliases for all commands adding version information 65 postInstall = '' 66 # Teardown the illusory postgres used for building; see postConfigure. 67 rm $out/bin/postgres 68 69 for prog in $out/bin/*; do # */ 70 ln -s $prog $prog-${version} 71 done 72 73 mkdir -p $doc/share/doc/postgis 74 mv doc/* $doc/share/doc/postgis/ 75 ''; 76 77 passthru.tests.postgis = nixosTests.postgis; 78 79 meta = with lib; { 80 description = "Geographic Objects for PostgreSQL"; 81 homepage = "https://postgis.net/"; 82 changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${version}/NEWS"; 83 license = licenses.gpl2Plus; 84 maintainers = with maintainers; teams.geospatial.members ++ [ marcweber wolfgangwalther ]; 85 inherit (postgresql.meta) platforms; 86 }; 87}