2015-02-20 02:05:49 +00:00
|
|
|
args@{fetchurl, composableDerivation, 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
|
|
|
|
2016-02-27 00:37:57 +00:00
|
|
|
services.postgresql.extraPlugins = [ (pkgs.postgis.override { postgresql = pkgs.postgresql95; }).v_2_2_1 ];
|
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
|
|
|
|
pgDerivationBase = composableDerivation.composableDerivation {} ( fix :
|
|
|
|
|
|
|
|
let version = fix.fixed.version; in {
|
|
|
|
|
|
|
|
name = "postgis-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2014-12-30 13:26:50 +00:00
|
|
|
url = "http://postgis.refractions.net/download/postgis-${fix.fixed.version}.tar.gz";
|
2010-05-26 20:01:10 +01:00
|
|
|
inherit (fix.fixed) sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
# don't pass these vars to the builder
|
|
|
|
removeAttrs = ["hash" "sql_comments" "sql_srcs"];
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
configureFlags="--datadir=$out/share --datarootdir=$out/share --bindir=$out/bin"
|
|
|
|
makeFlags="PERL=${perl}/bin/perl datadir=$out/share pkglibdir=$out/lib bindir=$out/bin"
|
|
|
|
'';
|
|
|
|
|
2014-12-30 13:26:50 +00:00
|
|
|
# create aliases for all commands adding version information
|
2010-05-26 20:01:10 +01:00
|
|
|
postInstall = ''
|
|
|
|
|
|
|
|
sql_srcs=$(for sql in ${builtins.toString fix.fixed.sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done )
|
|
|
|
|
2014-12-30 13:26:50 +00:00
|
|
|
for prog in $out/bin/*; do # */
|
2010-05-26 20:01:10 +01:00
|
|
|
ln -s $prog $prog-${version}
|
|
|
|
done
|
|
|
|
|
|
|
|
cp -r doc $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [libxml2 postgresql geos proj perl];
|
|
|
|
|
|
|
|
sql_comments = "postgis_comments.sql";
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Geographic Objects for PostgreSQL";
|
|
|
|
homepage = "http://postgis.refractions.net";
|
2014-06-19 05:19:00 +01:00
|
|
|
license = stdenv.lib.licenses.gpl2;
|
2010-05-26 20:01:10 +01:00
|
|
|
maintainers = [stdenv.lib.maintainers.marcweber];
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2014-12-30 13:26:50 +00:00
|
|
|
pgDerivationBaseNewer = pgDerivationBase.merge (fix: {
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://download.osgeo.org/postgis/source/postgis-${builtins.toString fix.fixed.version}.tar.gz";
|
|
|
|
inherit (fix.fixed) sha256;
|
|
|
|
};
|
|
|
|
});
|
2010-05-26 20:01:10 +01:00
|
|
|
|
|
|
|
in rec {
|
|
|
|
|
2016-02-27 00:37:57 +00:00
|
|
|
v_2_2_1 = pgDerivationBaseNewer.merge ( fix : {
|
|
|
|
version = "2.2.1";
|
|
|
|
sha256 = "02gsi1cm63kf0r7881444lrkzdjqhhpz9a5zav3al0q24nq01r8g";
|
2014-12-30 13:26:50 +00:00
|
|
|
sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
|
2015-02-20 02:05:49 +00:00
|
|
|
builtInputs = [gdal json_c pkgconfig];
|
2016-05-15 01:37:10 +01:00
|
|
|
|
|
|
|
# postgis config directory assumes /include /lib from the same root for json-c library
|
|
|
|
NIX_LDFLAGS = "-L${stdenv.lib.getLib json_c}/lib";
|
|
|
|
|
2014-12-30 13:26:50 +00:00
|
|
|
dontDisableStatic = true;
|
|
|
|
preConfigure = ''
|
|
|
|
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
|
2016-04-16 18:34:57 +01:00
|
|
|
configureFlags="$configureFlags --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}"
|
2014-12-30 13:26:50 +00:00
|
|
|
'';
|
|
|
|
postConfigure = ''
|
|
|
|
sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
|
2015-01-28 08:33:03 +00:00
|
|
|
s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
|
2014-12-30 13:26:50 +00:00
|
|
|
" \
|
|
|
|
"raster/loader/Makefile";
|
2015-01-28 08:33:03 +00:00
|
|
|
sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
|
2014-12-30 13:26:50 +00:00
|
|
|
" \
|
|
|
|
"raster/scripts/python/Makefile";
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
2015-02-20 02:05:49 +00:00
|
|
|
}
|