diff --git a/pkgs/postgis/postgis.nix b/pkgs/postgis/postgis.nix index ee1669e5..251d79ff 100644 --- a/pkgs/postgis/postgis.nix +++ b/pkgs/postgis/postgis.nix @@ -1,20 +1,26 @@ -{ fetchurl -, lib, stdenv -, perl -, libxml2 -, postgresql -, geos -, proj -, gdalMinimal -, json_c -, pkg-config -, file -, protobufc -, libiconv -, pcre2 -, nixosTests -, jitSupport -, llvm +{ + fetchurl, + lib, + stdenv, + perl, + libxml2, + postgresql, + postgresqlTestHook, + geos, + proj, + gdalMinimal, + json_c, + pkg-config, + file, + protobufc, + libiconv, + libxslt, + docbook_xml_dtd_45, + cunit, + pcre2, + nixosTests, + jitSupport, + llvm, }: let @@ -24,22 +30,44 @@ stdenv.mkDerivation rec { pname = "postgis"; version = "3.4.2"; - outputs = [ "out" "doc" ]; + outputs = [ + "out" + "doc" + ]; src = fetchurl { url = "https://download.osgeo.org/postgis/source/postgis-${version}.tar.gz"; - sha256 = "sha256-yMh0wAukqYSocDCva/lUSCFQIGCtRz1clvHU0INcWJI="; + hash = "sha256-yMh0wAukqYSocDCva/lUSCFQIGCtRz1clvHU0INcWJI="; }; - buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2.dev ] - ++ lib.optional stdenv.isDarwin libiconv; - nativeBuildInputs = [ perl pkg-config ] ++ lib.optional jitSupport llvm; + buildInputs = [ + libxml2 + postgresql + geos + proj + gdal + json_c + protobufc + pcre2.dev + ] ++ lib.optional stdenv.isDarwin libiconv; + nativeBuildInputs = [ + perl + pkg-config + ] ++ lib.optional jitSupport llvm; dontDisableStatic = true; + nativeCheckInputs = [ + postgresqlTestHook + cunit + libxslt + ]; + + postgresqlTestUserOptions = "LOGIN SUPERUSER"; + failureHook = "postgresqlStop"; + # postgis config directory assumes /include /lib from the same root for json-c library env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib"; - preConfigure = '' sed -i 's@/usr/bin/file@${file}/bin/file@' configure 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 { ln -s ${postgresql}/bin/postgres $out/bin/postgres ''; + doCheck = stdenv.isLinux; + + preCheck = '' + substituteInPlace regress/run_test.pl --replace-fail "/share/contrib/postgis" "$out/share/postgresql/contrib/postgis" + substituteInPlace regress/Makefile --replace-fail 's,\$$libdir,$(REGRESS_INSTALLDIR)/lib,g' "s,\\$\$libdir,$PWD/regress/00-regress-install$out/lib,g" \ + --replace-fail '$(REGRESS_INSTALLDIR)/share/contrib/postgis/*.sql' "$PWD/regress/00-regress-install$out/share/postgresql/contrib/postgis/*.sql" + 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" + ''; + # create aliases for all commands adding version information postInstall = '' # Teardown the illusory postgres used for building; see postConfigure. @@ -81,7 +118,13 @@ stdenv.mkDerivation rec { homepage = "https://postgis.net/"; changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${version}/NEWS"; license = licenses.gpl2Plus; - maintainers = with maintainers; teams.geospatial.members ++ [ marcweber wolfgangwalther ]; + maintainers = + with maintainers; + teams.geospatial.members + ++ [ + marcweber + wolfgangwalther + ]; inherit (postgresql.meta) platforms; }; }