commit
b7c3afa674
@ -1,24 +1,11 @@
|
|||||||
args@{fetchurl, composableDerivation, stdenv, perl, libxml2, postgresql, geos, proj, flex, ...}:
|
args@{fetchurl, composableDerivation, stdenv, perl, libxml2, postgresql, geos, proj, flex, gdal, pkgconfig, file, ...}:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
### NixOS - usage:
|
### NixOS - usage:
|
||||||
==================
|
==================
|
||||||
|
|
||||||
services.posgresql.extraPlugins = [ pkgs.postgis.v_1_5_1 ];
|
services.postgresql.extraPlugins = [ (pkgs.postgis.override { postgresql = pkgs.postgresql94; }).v_2_1_4 ];
|
||||||
|
|
||||||
or if you want to install 1.5.x and 1.3.x at the same time (which works
|
|
||||||
because the .sql and .so files have different names):
|
|
||||||
|
|
||||||
services.postgis.extraPlugins = [ (pkgs.buildEnv {
|
|
||||||
name = "postgis-plugins";
|
|
||||||
ignoreCollisions = 1; # scripts will collide - but there are aliases with version suffixes
|
|
||||||
paths = [ pkgs.postgis.v_1_3_5 pkgs.postgis.v_1_5_1 ];
|
|
||||||
})];
|
|
||||||
|
|
||||||
By now it is only supported installing one of the 1.3.x verions because
|
|
||||||
their shared libraries don't differ in naming.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### important Postgis implementation details:
|
### important Postgis implementation details:
|
||||||
@ -29,7 +16,7 @@ args@{fetchurl, composableDerivation, stdenv, perl, libxml2, postgresql, geos, p
|
|||||||
|
|
||||||
CREATE FUNCTION [...]
|
CREATE FUNCTION [...]
|
||||||
AS '[..]liblwgeom', 'lwhistogram2d_in' LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict);
|
AS '[..]liblwgeom', 'lwhistogram2d_in' LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict);
|
||||||
|
|
||||||
where liblwgeom is the shared library.
|
where liblwgeom is the shared library.
|
||||||
Postgis < 1.5 used absolute paths, in NixOS $libdir is always used.
|
Postgis < 1.5 used absolute paths, in NixOS $libdir is always used.
|
||||||
|
|
||||||
@ -37,7 +24,6 @@ args@{fetchurl, composableDerivation, stdenv, perl, libxml2, postgresql, geos, p
|
|||||||
systems you have to adopt the library path.
|
systems you have to adopt the library path.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### TODO:
|
### TODO:
|
||||||
=========
|
=========
|
||||||
the bin commands to have gtk gui:
|
the bin commands to have gtk gui:
|
||||||
@ -52,7 +38,7 @@ let
|
|||||||
name = "postgis-${version}";
|
name = "postgis-${version}";
|
||||||
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "http://download.osgeo.org/postgis/source/postgis-${fix.fixed.version}.tar.gz";
|
url = "http://postgis.refractions.net/download/postgis-${fix.fixed.version}.tar.gz";
|
||||||
inherit (fix.fixed) sha256;
|
inherit (fix.fixed) sha256;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,36 +50,12 @@ let
|
|||||||
makeFlags="PERL=${perl}/bin/perl datadir=$out/share pkglibdir=$out/lib bindir=$out/bin"
|
makeFlags="PERL=${perl}/bin/perl datadir=$out/share pkglibdir=$out/lib bindir=$out/bin"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
pg_db_postgis_enable = ./pg_db_postgis_enable.sh;
|
# create aliases for all commands adding version information
|
||||||
|
|
||||||
scriptNames = [ "pg_db_postgis_enable" ]; # helper scripts
|
|
||||||
|
|
||||||
# prepare fixed parameters for script and create pg_db_postgis_enable script.
|
|
||||||
# The script just loads postgis features into a list of given databases
|
|
||||||
postgisEnableScript = ''
|
|
||||||
s=$out/bin/pg_db_postgis_enable
|
|
||||||
|
|
||||||
sql_comments=$out/share/postgis-${version}/comments.sql
|
|
||||||
mkdir -p $(dirname $sql_comments)
|
|
||||||
cp $(find -iname ${fix.fixed.sql_comments}) $sql_comments
|
|
||||||
|
|
||||||
for script in $scriptNames; do
|
|
||||||
tg=$out/bin/$script
|
|
||||||
substituteAll ''${!script} $tg
|
|
||||||
chmod +x $tg
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
|
|
||||||
# create a script enabling postgis features
|
|
||||||
# also create aliases for all commands adding version information
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
|
|
||||||
sql_srcs=$(for sql in ${builtins.toString fix.fixed.sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done )
|
sql_srcs=$(for sql in ${builtins.toString fix.fixed.sql_srcs}; do echo -n "$(find $out -iname "$sql") "; done )
|
||||||
|
|
||||||
eval "$postgisEnableScript"
|
for prog in $out/bin/*; do # */
|
||||||
eval "$postgisFixLibScript"
|
|
||||||
|
|
||||||
for prog in $out/bin/*; do
|
|
||||||
ln -s $prog $prog-${version}
|
ln -s $prog $prog-${version}
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -113,38 +75,34 @@ let
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
in rec {
|
in rec {
|
||||||
|
|
||||||
# these builders just add some custom informaton to the receipe above
|
v_2_1_4 = pgDerivationBaseNewer.merge ( fix : {
|
||||||
|
version = "2.1.4";
|
||||||
v_1_3_5 = pgDerivationBase.merge ( fix: {
|
sha256 = "1z00n5654r7l38ydkn2grbwl5gg0mravjwxfdipp7j18hjiw4wyd";
|
||||||
version = "1.3.5";
|
sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
|
||||||
buildInputs = [ flex ];
|
builtInputs = [gdal pkgconfig];
|
||||||
sha256 = "102d5ybn0db1wrb249dga2v8347vysd4f1brc8zb82d7vdd34wyq";
|
dontDisableStatic = true;
|
||||||
sql_srcs = ["lwpostgis.sql" "spatial_ref_sys.sql"];
|
preConfigure = ''
|
||||||
|
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
|
||||||
pg_db_postgis_fix_or_load_sql_dump = ./pg_db_postgis_fix_or_load_sql_dump.sh;
|
configureFlags="$configureFlags --with-gdalconfig=${gdal}/bin/gdal-config"
|
||||||
libName = "liblwgeom";
|
'';
|
||||||
scriptNames = [ "pg_db_postgis_enable" "pg_db_postgis_fix_or_load_sql_dump"]; # helper scripts
|
postConfigure = ''
|
||||||
|
sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
|
||||||
# sql_srcs is defined in postInstall source above
|
s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
|
||||||
# if store path changes sql should not break. So replace absolute path to
|
" \
|
||||||
# shared library by path relatve to $libdir known by Postgres.
|
"raster/loader/Makefile";
|
||||||
postInstall = ''
|
sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g
|
||||||
sed -i "s@AS '$out/lib/liblwgeom@AS '\$libdir/liblwgeom@" $sql_srcs $out/share/lwpostgis_upgrade.sql
|
" \
|
||||||
|
"raster/scripts/python/Makefile";
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
v_1_3_6 = v_1_3_5.merge ({
|
}
|
||||||
version = "1.3.6";
|
|
||||||
sha256 = "0i6inyiwc5zgf5a4ssg0y774f8vn45zn5c38ccgnln9r6i54vc6k";
|
|
||||||
});
|
|
||||||
|
|
||||||
v_1_5_8 = pgDerivationBase.merge ( fix : {
|
|
||||||
version = "1.5.8";
|
|
||||||
sha256 = "016qn2hk3w8rg60rqn91l2nfk9zcsw0pv2s5rb1qhjw15ypgv5j8";
|
|
||||||
sql_srcs = ["postgis.sql" "spatial_ref_sys.sql"];
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user