2018-02-20 21:17:16 +00:00
|
|
|
{ fetchurl
|
2021-01-11 07:54:33 +00:00
|
|
|
, lib, stdenv
|
2018-02-20 21:17:16 +00:00
|
|
|
, perl
|
|
|
|
, libxml2
|
|
|
|
, postgresql
|
|
|
|
, geos
|
|
|
|
, proj
|
|
|
|
, gdal
|
|
|
|
, json_c
|
|
|
|
, pkgconfig
|
|
|
|
, file
|
2019-04-12 16:01:36 +01:00
|
|
|
, protobufc
|
2019-07-27 08:06:18 +01:00
|
|
|
, libiconv
|
2020-11-21 04:20:00 +00:00
|
|
|
, nixosTests
|
2018-02-20 21:17:16 +00:00
|
|
|
}:
|
2019-01-26 19:15:43 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "postgis";
|
2020-12-18 04:20:00 +00:00
|
|
|
version = "3.1.0";
|
2019-01-26 19:15:43 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "doc" ];
|
2018-02-20 21:17:16 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-01-26 19:15:43 +00:00
|
|
|
url = "https://download.osgeo.org/postgis/source/postgis-${version}.tar.gz";
|
2020-12-18 04:20:00 +00:00
|
|
|
sha256 = "008280ijd6m9h35y9lcpql0fk0h9f3zkc1pfkdm0rkbnd12y41ns";
|
2018-02-20 21:17:16 +00:00
|
|
|
};
|
|
|
|
|
2019-07-27 10:43:31 +01:00
|
|
|
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc ]
|
|
|
|
++ stdenv.lib.optional stdenv.isDarwin libiconv;
|
2019-04-12 16:01:36 +01:00
|
|
|
nativeBuildInputs = [ perl pkgconfig ];
|
2019-01-26 19:15:43 +00:00
|
|
|
dontDisableStatic = true;
|
2018-02-20 21:17:16 +00:00
|
|
|
|
|
|
|
# postgis config directory assumes /include /lib from the same root for json-c library
|
|
|
|
NIX_LDFLAGS = "-L${stdenv.lib.getLib json_c}/lib";
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
|
2019-07-01 15:18:03 +01:00
|
|
|
configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}"
|
2019-01-26 19:15:43 +00:00
|
|
|
|
2019-07-01 15:18:03 +01:00
|
|
|
makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin"
|
2018-02-20 21:17:16 +00:00
|
|
|
'';
|
|
|
|
postConfigure = ''
|
|
|
|
sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
|
|
|
|
s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
|
|
|
|
" \
|
|
|
|
"raster/loader/Makefile";
|
|
|
|
sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
|
|
|
|
" \
|
|
|
|
"raster/scripts/python/Makefile";
|
2019-01-26 19:15:43 +00:00
|
|
|
mkdir -p $out/bin
|
2019-07-31 23:16:59 +01:00
|
|
|
|
|
|
|
# postgis' build system assumes it is being installed to the same place as postgresql, and looks
|
|
|
|
# for the postgres binary relative to $PREFIX. We gently support this system using an illusion.
|
2019-07-27 08:06:18 +01:00
|
|
|
ln -s ${postgresql}/bin/postgres $out/bin/postgres
|
2019-01-26 19:15:43 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# create aliases for all commands adding version information
|
|
|
|
postInstall = ''
|
2019-07-31 23:16:59 +01:00
|
|
|
# Teardown the illusory postgres used for building; see postConfigure.
|
2019-07-27 08:06:18 +01:00
|
|
|
rm $out/bin/postgres
|
2019-07-31 23:16:59 +01:00
|
|
|
|
2019-01-26 19:15:43 +00:00
|
|
|
for prog in $out/bin/*; do # */
|
|
|
|
ln -s $prog $prog-${version}
|
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -p $doc/share/doc/postgis
|
|
|
|
mv doc/* $doc/share/doc/postgis/
|
|
|
|
'';
|
|
|
|
|
2020-11-21 04:20:00 +00:00
|
|
|
passthru.tests.postgis = nixosTests.postgis;
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2018-02-20 21:17:16 +00:00
|
|
|
description = "Geographic Objects for PostgreSQL";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://postgis.net/";
|
2019-09-01 22:20:00 +01:00
|
|
|
changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${version}/NEWS";
|
2018-02-20 21:17:16 +00:00
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = [ maintainers.marcweber ];
|
2019-07-31 23:21:07 +01:00
|
|
|
inherit (postgresql.meta) platforms;
|
2018-02-20 21:17:16 +00:00
|
|
|
};
|
2015-02-20 02:05:49 +00:00
|
|
|
}
|