2018-02-20 21:17:16 +00:00
|
|
|
{ fetchurl
|
2018-03-05 15:45:02 +00:00
|
|
|
, fetchpatch
|
2018-02-20 21:17:16 +00:00
|
|
|
, stdenv
|
|
|
|
, perl
|
|
|
|
, libxml2
|
|
|
|
, postgresql
|
|
|
|
, geos
|
|
|
|
, proj
|
|
|
|
, flex
|
|
|
|
, gdal
|
|
|
|
, json_c
|
|
|
|
, pkgconfig
|
|
|
|
, file
|
|
|
|
}:
|
2010-05-09 21:38:16 +01:00
|
|
|
|
2010-05-26 20:01:10 +01:00
|
|
|
/*
|
2010-05-09 21:38:16 +01:00
|
|
|
|
2010-05-26 20:01:10 +01:00
|
|
|
### NixOS - usage:
|
|
|
|
==================
|
2010-05-09 21:38:16 +01:00
|
|
|
|
2018-02-20 21:17:16 +00:00
|
|
|
services.postgresql.extraPlugins = [ (pkgs.postgis.override { postgresql = pkgs.postgresql95; }) ];
|
2010-05-26 20:01:10 +01:00
|
|
|
|
|
|
|
|
|
|
|
### important Postgis implementation details:
|
|
|
|
=============================================
|
|
|
|
|
|
|
|
Postgis provides a shared library implementing many operations. They are
|
|
|
|
exposed to the Postgres SQL interpreter by special SQL queries eg:
|
|
|
|
|
|
|
|
CREATE FUNCTION [...]
|
|
|
|
AS '[..]liblwgeom', 'lwhistogram2d_in' LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict);
|
2015-02-09 15:57:19 +00:00
|
|
|
|
2010-05-26 20:01:10 +01:00
|
|
|
where liblwgeom is the shared library.
|
|
|
|
Postgis < 1.5 used absolute paths, in NixOS $libdir is always used.
|
|
|
|
|
|
|
|
Thus if you want to use postgresql dumps which were created by non NixOS
|
|
|
|
systems you have to adopt the library path.
|
|
|
|
|
|
|
|
|
|
|
|
### TODO:
|
|
|
|
=========
|
|
|
|
the bin commands to have gtk gui:
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
let
|
2018-05-31 18:39:53 +01:00
|
|
|
version = "2.4.4";
|
|
|
|
sha256 = "1hm8migjb53cymp4qvg1h20yqllmy9f7x0awv5450391i6syyqq6";
|
2018-02-20 21:17:16 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "postgis-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2018-06-28 19:43:35 +01:00
|
|
|
url = "https://download.osgeo.org/postgis/source/postgis-${builtins.toString version}.tar.gz";
|
2018-02-20 21:17:16 +00:00
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
# don't pass these vars to the builder
|
|
|
|
removeAttrs = ["sql_comments" "sql_srcs"];
|
|
|
|
|
2018-03-05 15:45:02 +00:00
|
|
|
preInstall = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
'';
|
|
|
|
|
2018-02-20 21:17:16 +00:00
|
|
|
# create aliases for all commands adding version information
|
|
|
|
postInstall = ''
|
|
|
|
sql_srcs=$(for sql in ${builtins.toString sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done )
|
|
|
|
|
|
|
|
for prog in $out/bin/*; do # */
|
|
|
|
ln -s $prog $prog-${version}
|
|
|
|
done
|
|
|
|
|
|
|
|
cp -r doc $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [ libxml2 postgresql geos proj perl gdal json_c pkgconfig ];
|
|
|
|
|
|
|
|
sql_comments = "postgis_comments.sql";
|
|
|
|
|
|
|
|
sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
|
|
|
|
|
|
|
|
# postgis config directory assumes /include /lib from the same root for json-c library
|
|
|
|
NIX_LDFLAGS = "-L${stdenv.lib.getLib json_c}/lib";
|
|
|
|
|
|
|
|
dontDisableStatic = true;
|
|
|
|
preConfigure = ''
|
|
|
|
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
|
|
|
|
configureFlags="--datadir=$out/share --datarootdir=$out/share --bindir=$out/bin --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}"
|
|
|
|
makeFlags="PERL=${perl}/bin/perl datadir=$out/share 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";
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Geographic Objects for PostgreSQL";
|
|
|
|
homepage = http://postgis.refractions.net;
|
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = [ maintainers.marcweber ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
2015-02-20 02:05:49 +00:00
|
|
|
}
|