nixpkgs/pkgs/servers/sql/postgresql/ext/postgis.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

170 lines
4 KiB
Nix
Raw Normal View History

{
fetchFromGitHub,
lib,
stdenv,
perl,
libxml2,
postgresql,
postgresqlTestHook,
geos,
proj,
gdalMinimal,
json_c,
pkg-config,
file,
protobufc,
libiconv,
libxslt,
docbook5,
cunit,
pcre2,
postgresqlTestExtension,
jitSupport,
llvm,
buildPostgresqlExtension,
autoconf,
automake,
libtool,
which,
2024-12-19 23:28:16 +01:00
sfcgal,
withSfcgal ? false,
}:
let
gdal = gdalMinimal;
in
buildPostgresqlExtension (finalAttrs: {
pname = "postgis";
version = "3.5.2";
outputs = [
"out"
"doc"
];
src = fetchFromGitHub {
owner = "postgis";
repo = "postgis";
rev = "${finalAttrs.version}";
hash = "sha256-1kOLtG6AMavbWQ1lHG2ABuvIcyTYhgcbjuVmqMR4X+g=";
};
2024-12-19 23:28:16 +01:00
buildInputs =
[
geos
proj
gdal
json_c
protobufc
pcre2.dev
]
++ lib.optional stdenv.hostPlatform.isDarwin libiconv
++ lib.optional withSfcgal sfcgal;
nativeBuildInputs = [
autoconf
automake
libtool
2025-02-01 10:25:22 +01:00
libxml2
perl
pkg-config
2025-02-01 10:25:22 +01:00
protobufc
which
] ++ 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
llvmPackages_{12,13,14,15,16,17,git}.{libcxx,libcxxabi}: merge libcxxabi into libcxx (#292043) - merge libcxxabi into libcxx for LLVM 12, 13, 14, 15, 16, 17, and git. - remove the link time workaround `-lc++ -lc++abi` from 58 packages as it is no longer required. - fixes https://github.com/NixOS/nixpkgs/issues/166205 - provides alternative fixes for. https://github.com/NixOS/nixpkgs/issues/269548 https://github.com/NixOS/nix/issues/9640 - pkgsCross.x86_64-freebsd builds work again This change can be represented in 3 stages 1. merge libcxxabi into libcxx -- files: pkgs/development/compilers/llvm/[12, git]/{libcxx, libcxxabi} 2. update stdenv to account for merge -- files: stdenv.{adapters, cc.wrapper, darwin} 3. remove all references to libcxxabi outside of llvm (about 58 packages modified) ### merging libcxxabi into libcxx - take the union of the libcxxabi and libcxx cmake flags - eliminate the libcxx-headers-only package - it was only needed to break libcxx <-> libcxxabi circular dependency - libcxx.cxxabi is removed. external cxxabi (freebsd) will symlink headers / libs into libcxx. - darwin will re-export the libcxxabi symbols into libcxx so linking `-lc++` is sufficient. - linux/freebsd `libc++.so` is a linker script `LINK(libc++.so.1, -lc++abi)` making `-lc++` sufficient. - libcxx/default.nix [12, 17] are identical except for patches and `LIBCXX_ADDITIONAL_LIBRARIES` (only used in 16+) - git/libcxx/defaul.nix does not link with -nostdlib when useLLVM is true so flag is removed. this is not much different than before as libcxxabi used -nostdlib where libcxx did not, so libc was linked in anyway. ### stdenv changes - darwin bootstrap, remove references to libcxxabi and cxxabi - cc-wrapper: remove c++ link workaround when libcxx.cxxabi doesn't exist (still exists for LLVM pre 12) - adapter: update overrideLibcxx to account for a pkgs.stdenv that only has libcxx ### 58 package updates - remove `NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}` as no longer needed - swift, nodejs_v8 remove libcxxabi references in the clang override https://github.com/NixOS/nixpkgs/pull/292043
2024-03-11 03:53:37 -07:00
env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";
setOutputFlags = false;
preConfigure = ''
./autogen.sh
'';
configureFlags = [
"--with-gdalconfig=${gdal}/bin/gdal-config"
"--with-jsondir=${json_c.dev}"
"--disable-extension-upgrades-install"
2024-12-19 23:28:16 +01:00
] ++ lib.optional withSfcgal "--with-sfcgal=${sfcgal}/bin/sfcgal-config";
makeFlags = [
"PERL=${perl}/bin/perl"
];
doCheck = stdenv.hostPlatform.isLinux;
preCheck = ''
substituteInPlace doc/postgis-out.xml --replace-fail "http://docbook.org/xml/5.0/dtd/docbook.dtd" "${docbook5}/xml/dtd/docbook/docbookx.dtd"
# The test suite hardcodes it to use /tmp.
export PGIS_REG_TMPDIR="$TMPDIR/pgis_reg"
'';
# create aliases for all commands adding version information
postInstall = ''
for prog in $out/bin/*; do # */
ln -s $prog $prog-${finalAttrs.version}
done
mkdir -p $doc/share/doc/postgis
mv doc/* $doc/share/doc/postgis/
'';
passthru.tests.extension = postgresqlTestExtension {
inherit (finalAttrs) finalPackage;
sql =
let
expectedVersion = "${lib.versions.major finalAttrs.version}.${lib.versions.minor finalAttrs.version} USE_GEOS=1 USE_PROJ=1 USE_STATS=1";
in
''
CREATE EXTENSION postgis;
CREATE EXTENSION postgis_raster;
CREATE EXTENSION postgis_topology;
select postgis_version();
do $$
begin
if postgis_version() <> '${expectedVersion}' then
raise '"%" does not match "${expectedVersion}"', postgis_version();
end if;
end$$;
-- st_makepoint goes through c code
select st_makepoint(1, 1);
2024-12-19 23:28:16 +01:00
''
+ lib.optionalString withSfcgal ''
CREATE EXTENSION postgis_sfcgal;
do $$
begin
if postgis_sfcgal_version() <> '${sfcgal.version}' then
raise '"%" does not match "${sfcgal.version}"', postgis_sfcgal_version();
end if;
end$$;
CREATE TABLE geometries (
name varchar,
geom geometry(PolygonZ) NOT NULL
);
INSERT INTO geometries(name, geom) VALUES
('planar geom', 'PolygonZ((1 1 0, 1 2 0, 2 2 0, 2 1 0, 1 1 0))'),
('nonplanar geom', 'PolygonZ((1 1 1, 1 2 -1, 2 2 2, 2 1 0, 1 1 1))');
SELECT name from geometries where cg_isplanar(geom);
'';
};
meta = with lib; {
description = "Geographic Objects for PostgreSQL";
homepage = "https://postgis.net/";
changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${finalAttrs.version}/NEWS";
2024-05-23 11:44:51 +03:00
license = licenses.gpl2Plus;
maintainers = with maintainers; teams.geospatial.members ++ [ marcweber ];
inherit (postgresql.meta) platforms;
};
})