2020-04-24 23:36:52 +00:00
|
|
|
{ fetchurl
|
2021-01-15 22:18:51 +00:00
|
|
|
, lib, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
, perl
|
|
|
|
, libxml2
|
|
|
|
, postgresql
|
|
|
|
, geos
|
|
|
|
, proj
|
|
|
|
, gdal
|
|
|
|
, json_c
|
2021-02-05 17:12:51 +00:00
|
|
|
, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
, file
|
|
|
|
, protobufc
|
|
|
|
, libiconv
|
2020-11-24 20:58:05 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "postgis";
|
2022-09-09 14:08:57 +00:00
|
|
|
version = "3.3.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
outputs = [ "out" "doc" ];
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://download.osgeo.org/postgis/source/postgis-${version}.tar.gz";
|
2022-09-09 14:08:57 +00:00
|
|
|
sha256 = "sha256-aWe3f3yKcjqHa+wmWPgqbLfytt3/sEgKsG0zcnivYFU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc ]
|
2021-01-15 22:18:51 +00:00
|
|
|
++ lib.optional stdenv.isDarwin libiconv;
|
2021-02-05 17:12:51 +00:00
|
|
|
nativeBuildInputs = [ perl pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
dontDisableStatic = true;
|
|
|
|
|
|
|
|
# postgis config directory assumes /include /lib from the same root for json-c library
|
2021-01-15 22:18:51 +00:00
|
|
|
NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
|
|
|
|
configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}"
|
|
|
|
|
|
|
|
makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin"
|
|
|
|
'';
|
|
|
|
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";
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
ln -s ${postgresql}/bin/postgres $out/bin/postgres
|
|
|
|
'';
|
|
|
|
|
|
|
|
# create aliases for all commands adding version information
|
|
|
|
postInstall = ''
|
|
|
|
# Teardown the illusory postgres used for building; see postConfigure.
|
|
|
|
rm $out/bin/postgres
|
|
|
|
|
|
|
|
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-24 20:58:05 +00:00
|
|
|
passthru.tests.postgis = nixosTests.postgis;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Geographic Objects for PostgreSQL";
|
|
|
|
homepage = "https://postgis.net/";
|
|
|
|
changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${version}/NEWS";
|
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = [ maintainers.marcweber ];
|
|
|
|
inherit (postgresql.meta) platforms;
|
|
|
|
};
|
|
|
|
}
|