Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
postgresql-postgis: enable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imincik committed Aug 15, 2024
1 parent fa6cf8e commit 195a32f
Showing 1 changed file with 67 additions and 24 deletions.
91 changes: 67 additions & 24 deletions pkgs/postgis/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;
};
}

0 comments on commit 195a32f

Please sign in to comment.