···1-args@{fetchurl, composableDerivation, stdenv, perl, libxml2, postgresql, geos, proj, flex, ...}:
23 /*
45 ### NixOS - usage:
6 ==================
78- services.posgresql.extraPlugins = [ pkgs.postgis.v_1_5_1 ];
9-10- or if you want to install 1.5.x and 1.3.x at the same time (which works
11- because the .sql and .so files have different names):
12-13- services.postgis.extraPlugins = [ (pkgs.buildEnv {
14- name = "postgis-plugins";
15- ignoreCollisions = 1; # scripts will collide - but there are aliases with version suffixes
16- paths = [ pkgs.postgis.v_1_3_5 pkgs.postgis.v_1_5_1 ];
17- })];
18-19- By now it is only supported installing one of the 1.3.x verions because
20- their shared libraries don't differ in naming.
21-222324 ### important Postgis implementation details:
···2930 CREATE FUNCTION [...]
31 AS '[..]liblwgeom', 'lwhistogram2d_in' LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict);
32-33 where liblwgeom is the shared library.
34 Postgis < 1.5 used absolute paths, in NixOS $libdir is always used.
3536 Thus if you want to use postgresql dumps which were created by non NixOS
37 systems you have to adopt the library path.
38-394041 ### TODO:
···52 name = "postgis-${version}";
5354 src = fetchurl {
55- url = "http://download.osgeo.org/postgis/source/postgis-${fix.fixed.version}.tar.gz";
56 inherit (fix.fixed) sha256;
57 };
58···64 makeFlags="PERL=${perl}/bin/perl datadir=$out/share pkglibdir=$out/lib bindir=$out/bin"
65 '';
6667- pg_db_postgis_enable = ./pg_db_postgis_enable.sh;
68-69- scriptNames = [ "pg_db_postgis_enable" ]; # helper scripts
70-71- # prepare fixed parameters for script and create pg_db_postgis_enable script.
72- # The script just loads postgis features into a list of given databases
73- postgisEnableScript = ''
74- s=$out/bin/pg_db_postgis_enable
75-76- sql_comments=$out/share/postgis-${version}/comments.sql
77- mkdir -p $(dirname $sql_comments)
78- cp $(find -iname ${fix.fixed.sql_comments}) $sql_comments
79-80- for script in $scriptNames; do
81- tg=$out/bin/$script
82- substituteAll ''${!script} $tg
83- chmod +x $tg
84- done
85- '';
86-87- # create a script enabling postgis features
88- # also create aliases for all commands adding version information
89 postInstall = ''
9091 sql_srcs=$(for sql in ${builtins.toString fix.fixed.sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done )
9293- eval "$postgisEnableScript"
94- eval "$postgisFixLibScript"
95-96- for prog in $out/bin/*; do
97 ln -s $prog $prog-${version}
98 done
99···113 };
114 });
115116-117-in rec {
118-119- # these builders just add some custom informaton to the receipe above
120-121- v_1_3_5 = pgDerivationBase.merge ( fix: {
122- version = "1.3.5";
123- buildInputs = [ flex ];
124- sha256 = "102d5ybn0db1wrb249dga2v8347vysd4f1brc8zb82d7vdd34wyq";
125- sql_srcs = ["lwpostgis.sql" "spatial_ref_sys.sql"];
126-127- pg_db_postgis_fix_or_load_sql_dump = ./pg_db_postgis_fix_or_load_sql_dump.sh;
128- libName = "liblwgeom";
129- scriptNames = [ "pg_db_postgis_enable" "pg_db_postgis_fix_or_load_sql_dump"]; # helper scripts
130-131- # sql_srcs is defined in postInstall source above
132- # if store path changes sql should not break. So replace absolute path to
133- # shared library by path relatve to $libdir known by Postgres.
134- postInstall = ''
135- sed -i "s@AS '$out/lib/liblwgeom@AS '\$libdir/liblwgeom@" $sql_srcs $out/share/lwpostgis_upgrade.sql
136- '';
137 });
138139- v_1_3_6 = v_1_3_5.merge ({
140- version = "1.3.6";
141- sha256 = "0i6inyiwc5zgf5a4ssg0y774f8vn45zn5c38ccgnln9r6i54vc6k";
142- });
143144- v_1_5_8 = pgDerivationBase.merge ( fix : {
145- version = "1.5.8";
146- sha256 = "016qn2hk3w8rg60rqn91l2nfk9zcsw0pv2s5rb1qhjw15ypgv5j8";
147 sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
000000000000000148 });
149150-}
···1+args@{fetchurl, composableDerivation, stdenv, perl, libxml2, postgresql, geos, proj, flex, gdal, pkgconfig, file, ...}:
23 /*
45 ### NixOS - usage:
6 ==================
78+ services.postgresql.extraPlugins = [ (pkgs.postgis.override { postgresql = pkgs.postgresql94; }).v_2_1_4 ];
000000000000091011 ### important Postgis implementation details:
···1617 CREATE FUNCTION [...]
18 AS '[..]liblwgeom', 'lwhistogram2d_in' LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict);
19+20 where liblwgeom is the shared library.
21 Postgis < 1.5 used absolute paths, in NixOS $libdir is always used.
2223 Thus if you want to use postgresql dumps which were created by non NixOS
24 systems you have to adopt the library path.
0252627 ### TODO:
···38 name = "postgis-${version}";
3940 src = fetchurl {
41+ url = "http://postgis.refractions.net/download/postgis-${fix.fixed.version}.tar.gz";
42 inherit (fix.fixed) sha256;
43 };
44···50 makeFlags="PERL=${perl}/bin/perl datadir=$out/share pkglibdir=$out/lib bindir=$out/bin"
51 '';
5253+ # create aliases for all commands adding version information
00000000000000000000054 postInstall = ''
5556 sql_srcs=$(for sql in ${builtins.toString fix.fixed.sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done )
5758+ for prog in $out/bin/*; do # */
00059 ln -s $prog $prog-${version}
60 done
61···75 };
76 });
7778+ pgDerivationBaseNewer = pgDerivationBase.merge (fix: {
79+ src = fetchurl {
80+ url = "http://download.osgeo.org/postgis/source/postgis-${builtins.toString fix.fixed.version}.tar.gz";
81+ inherit (fix.fixed) sha256;
82+ };
000000000000000083 });
8485+in rec {
0008687+ v_2_1_4 = pgDerivationBaseNewer.merge ( fix : {
88+ version = "2.1.4";
89+ sha256 = "1z00n5654r7l38ydkn2grbwl5gg0mravjwxfdipp7j18hjiw4wyd";
90 sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
91+ builtInputs = [gdal pkgconfig];
92+ dontDisableStatic = true;
93+ preConfigure = ''
94+ sed -i 's@/usr/bin/file@${file}/bin/file@' configure
95+ configureFlags="$configureFlags --with-gdalconfig=${gdal}/bin/gdal-config"
96+ '';
97+ postConfigure = ''
98+ sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
99+ s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
100+ " \
101+ "raster/loader/Makefile";
102+ sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
103+ " \
104+ "raster/scripts/python/Makefile";
105+ '';
106 });
107108+}