at 18.09-beta 105 lines 2.9 kB view raw
1{ fetchurl 2, stdenv 3, perl 4, libxml2 5, postgresql 6, geos 7, proj 8, gdal 9, json_c 10, pkgconfig 11, file 12}: 13 14 /* 15 16 ### NixOS - usage: 17 ================== 18 19 services.postgresql.extraPlugins = [ (pkgs.postgis.override { postgresql = pkgs.postgresql95; }) ]; 20 21 22 ### important Postgis implementation details: 23 ============================================= 24 25 Postgis provides a shared library implementing many operations. They are 26 exposed to the Postgres SQL interpreter by special SQL queries eg: 27 28 CREATE FUNCTION [...] 29 AS '[..]liblwgeom', 'lwhistogram2d_in' LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict); 30 31 where liblwgeom is the shared library. 32 Postgis < 1.5 used absolute paths, in NixOS $libdir is always used. 33 34 Thus if you want to use postgresql dumps which were created by non NixOS 35 systems you have to adopt the library path. 36 37 38 ### TODO: 39 ========= 40 the bin commands to have gtk gui: 41 */ 42 43 44let 45 version = "2.4.4"; 46 sha256 = "1hm8migjb53cymp4qvg1h20yqllmy9f7x0awv5450391i6syyqq6"; 47in stdenv.mkDerivation rec { 48 name = "postgis-${version}"; 49 50 src = fetchurl { 51 url = "https://download.osgeo.org/postgis/source/postgis-${builtins.toString version}.tar.gz"; 52 inherit sha256; 53 }; 54 55 # don't pass these vars to the builder 56 removeAttrs = ["sql_comments" "sql_srcs"]; 57 58 preInstall = '' 59 mkdir -p $out/bin 60 ''; 61 62 # create aliases for all commands adding version information 63 postInstall = '' 64 sql_srcs=$(for sql in ${builtins.toString sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done ) 65 66 for prog in $out/bin/*; do # */ 67 ln -s $prog $prog-${version} 68 done 69 70 cp -r doc $out 71 ''; 72 73 buildInputs = [ libxml2 postgresql geos proj perl gdal json_c pkgconfig ]; 74 75 sql_comments = "postgis_comments.sql"; 76 77 sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"]; 78 79 # postgis config directory assumes /include /lib from the same root for json-c library 80 NIX_LDFLAGS = "-L${stdenv.lib.getLib json_c}/lib"; 81 82 dontDisableStatic = true; 83 preConfigure = '' 84 sed -i 's@/usr/bin/file@${file}/bin/file@' configure 85 configureFlags="--datadir=$out/share --datarootdir=$out/share --bindir=$out/bin --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}" 86 makeFlags="PERL=${perl}/bin/perl datadir=$out/share pkglibdir=$out/lib bindir=$out/bin" 87 ''; 88 postConfigure = '' 89 sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ; 90 s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g 91 " \ 92 "raster/loader/Makefile"; 93 sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g 94 " \ 95 "raster/scripts/python/Makefile"; 96 ''; 97 98 meta = with stdenv.lib; { 99 description = "Geographic Objects for PostgreSQL"; 100 homepage = http://postgis.refractions.net; 101 license = licenses.gpl2; 102 maintainers = [ maintainers.marcweber ]; 103 platforms = platforms.linux; 104 }; 105}