Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgresqlPackages.postgis: enable tests #331876

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 67 additions & 24 deletions pkgs/servers/sql/postgresql/ext/postgis.nix
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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.
Expand All @@ -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;
};
}