1- { fetchurl
2- , lib , stdenv
3- , perl
4- , libxml2
5- , postgresql
6- , geos
7- , proj
8- , gdalMinimal
9- , json_c
10- , pkg-config
11- , file
12- , protobufc
13- , libiconv
14- , pcre2
15- , nixosTests
16- , jitSupport
17- , llvm
1+ {
2+ fetchurl ,
3+ lib ,
4+ stdenv ,
5+ perl ,
6+ libxml2 ,
7+ postgresql ,
8+ postgresqlTestHook ,
9+ geos ,
10+ proj ,
11+ gdalMinimal ,
12+ json_c ,
13+ pkg-config ,
14+ file ,
15+ protobufc ,
16+ libiconv ,
17+ libxslt ,
18+ docbook_xml_dtd_45 ,
19+ cunit ,
20+ pcre2 ,
21+ nixosTests ,
22+ jitSupport ,
23+ llvm ,
1824} :
1925
2026let
@@ -24,22 +30,44 @@ stdenv.mkDerivation rec {
2430 pname = "postgis" ;
2531 version = "3.4.2" ;
2632
27- outputs = [ "out" "doc" ] ;
33+ outputs = [
34+ "out"
35+ "doc"
36+ ] ;
2837
2938 src = fetchurl {
3039 url = "https://download.osgeo.org/postgis/source/postgis-${ version } .tar.gz" ;
31- sha256 = "sha256-yMh0wAukqYSocDCva/lUSCFQIGCtRz1clvHU0INcWJI=" ;
40+ hash = "sha256-yMh0wAukqYSocDCva/lUSCFQIGCtRz1clvHU0INcWJI=" ;
3241 } ;
3342
34- buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2 . dev ]
35- ++ lib . optional stdenv . isDarwin libiconv ;
36- nativeBuildInputs = [ perl pkg-config ] ++ lib . optional jitSupport llvm ;
43+ buildInputs = [
44+ libxml2
45+ postgresql
46+ geos
47+ proj
48+ gdal
49+ json_c
50+ protobufc
51+ pcre2 . dev
52+ ] ++ lib . optional stdenv . isDarwin libiconv ;
53+ nativeBuildInputs = [
54+ perl
55+ pkg-config
56+ ] ++ lib . optional jitSupport llvm ;
3757 dontDisableStatic = true ;
3858
59+ nativeCheckInputs = [
60+ postgresqlTestHook
61+ cunit
62+ libxslt
63+ ] ;
64+
65+ postgresqlTestUserOptions = "LOGIN SUPERUSER" ;
66+ failureHook = "postgresqlStop" ;
67+
3968 # postgis config directory assumes /include /lib from the same root for json-c library
4069 env . NIX_LDFLAGS = "-L${ lib . getLib json_c } /lib" ;
4170
42-
4371 preConfigure = ''
4472 sed -i 's@/usr/bin/file@${ file } /bin/file@' configure
4573 configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --docdir=$doc/share/doc/${ pname } --with-gdalconfig=${ gdal } /bin/gdal-config --with-jsondir=${ json_c . dev } --disable-extension-upgrades-install"
@@ -61,6 +89,15 @@ stdenv.mkDerivation rec {
6189 ln -s ${ postgresql } /bin/postgres $out/bin/postgres
6290 '' ;
6391
92+ doCheck = stdenv . isLinux ;
93+
94+ preCheck = ''
95+ substituteInPlace regress/run_test.pl --replace-fail "/share/contrib/postgis" "$out/share/postgresql/contrib/postgis"
96+ substituteInPlace regress/Makefile --replace-fail 's,\$$libdir,$(REGRESS_INSTALLDIR)/lib,g' "s,\\$\$libdir,$PWD/regress/00-regress-install$out/lib,g" \
97+ --replace-fail '$(REGRESS_INSTALLDIR)/share/contrib/postgis/*.sql' "$PWD/regress/00-regress-install$out/share/postgresql/contrib/postgis/*.sql"
98+ substituteInPlace doc/postgis-out.xml --replace-fail "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" "${ docbook_xml_dtd_45 } /xml/dtd/docbook/docbookx.dtd"
99+ '' ;
100+
64101 # create aliases for all commands adding version information
65102 postInstall = ''
66103 # Teardown the illusory postgres used for building; see postConfigure.
@@ -81,7 +118,13 @@ stdenv.mkDerivation rec {
81118 homepage = "https://postgis.net/" ;
82119 changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${ version } /NEWS" ;
83120 license = licenses . gpl2Plus ;
84- maintainers = with maintainers ; teams . geospatial . members ++ [ marcweber wolfgangwalther ] ;
121+ maintainers =
122+ with maintainers ;
123+ teams . geospatial . members
124+ ++ [
125+ marcweber
126+ wolfgangwalther
127+ ] ;
85128 inherit ( postgresql . meta ) platforms ;
86129 } ;
87130}
0 commit comments