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