2024-08-15 13:55:26 +10:00
|
|
|
{
|
2025-03-16 21:00:42 +01:00
|
|
|
autoconf,
|
|
|
|
automake,
|
|
|
|
cunit,
|
|
|
|
docbook5,
|
2024-11-15 21:44:56 +01:00
|
|
|
fetchFromGitHub,
|
2025-05-10 00:02:18 +03:00
|
|
|
fetchpatch,
|
2024-08-15 13:55:26 +10:00
|
|
|
gdalMinimal,
|
2025-03-16 21:00:42 +01:00
|
|
|
geos,
|
|
|
|
jitSupport,
|
2024-08-15 13:55:26 +10:00
|
|
|
json_c,
|
2025-03-16 21:00:42 +01:00
|
|
|
lib,
|
2024-08-15 13:55:26 +10:00
|
|
|
libiconv,
|
2025-03-16 21:00:42 +01:00
|
|
|
libtool,
|
|
|
|
libxml2,
|
2024-08-15 13:55:26 +10:00
|
|
|
libxslt,
|
2025-03-16 21:00:42 +01:00
|
|
|
llvm,
|
2024-08-15 13:55:26 +10:00
|
|
|
pcre2,
|
2025-03-16 21:00:42 +01:00
|
|
|
perl,
|
|
|
|
pkg-config,
|
|
|
|
postgresql,
|
2025-03-16 21:28:21 +01:00
|
|
|
postgresqlBuildExtension,
|
2024-11-01 19:32:30 +01:00
|
|
|
postgresqlTestExtension,
|
2025-03-16 21:00:42 +01:00
|
|
|
postgresqlTestHook,
|
|
|
|
proj,
|
|
|
|
protobufc,
|
|
|
|
stdenv,
|
2024-11-15 21:44:56 +01:00
|
|
|
which,
|
2025-03-16 21:00:42 +01:00
|
|
|
|
2024-12-19 23:28:16 +01:00
|
|
|
withSfcgal ? false,
|
2025-03-16 21:00:42 +01:00
|
|
|
sfcgal,
|
2018-02-20 22:17:16 +01:00
|
|
|
}:
|
2023-12-23 18:48:49 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
gdal = gdalMinimal;
|
|
|
|
in
|
2025-03-16 21:28:21 +01:00
|
|
|
postgresqlBuildExtension (finalAttrs: {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "postgis";
|
2025-01-20 10:30:23 +01:00
|
|
|
version = "3.5.2";
|
2019-01-26 21:15:43 +02:00
|
|
|
|
2024-08-15 13:55:26 +10:00
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"doc"
|
|
|
|
];
|
2018-02-20 22:17:16 +01:00
|
|
|
|
2024-11-15 21:44:56 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "postgis";
|
|
|
|
repo = "postgis";
|
2025-04-07 08:08:07 +02:00
|
|
|
tag = finalAttrs.version;
|
2025-01-20 10:30:23 +01:00
|
|
|
hash = "sha256-1kOLtG6AMavbWQ1lHG2ABuvIcyTYhgcbjuVmqMR4X+g=";
|
2018-02-20 22:17:16 +01:00
|
|
|
};
|
|
|
|
|
2025-05-10 00:02:18 +03:00
|
|
|
patches = [
|
|
|
|
# Backport patch for compatibility with GDAL 3.11
|
|
|
|
# FIXME: remove in next update
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://git.osgeo.org/gitea/postgis/postgis/commit/614eca7c169cd6e9819801d3ea99d5258262c58b.patch";
|
|
|
|
hash = "sha256-VkNZFANAt8Jv+ExCusGvi+ZWB7XLcAheefSx7akA7Go=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
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;
|
2025-03-16 21:00:42 +01:00
|
|
|
|
2024-08-15 13:55:26 +10:00
|
|
|
nativeBuildInputs = [
|
2024-11-15 21:44:56 +01:00
|
|
|
autoconf
|
|
|
|
automake
|
|
|
|
libtool
|
2025-02-01 10:25:22 +01:00
|
|
|
libxml2
|
2024-08-15 13:55:26 +10:00
|
|
|
perl
|
|
|
|
pkg-config
|
2025-02-01 10:25:22 +01:00
|
|
|
protobufc
|
2024-11-15 21:44:56 +01:00
|
|
|
which
|
2024-08-15 13:55:26 +10:00
|
|
|
] ++ lib.optional jitSupport llvm;
|
2025-03-16 21:00:42 +01:00
|
|
|
|
2019-01-26 21:15:43 +02:00
|
|
|
dontDisableStatic = true;
|
2018-02-20 22:17:16 +01:00
|
|
|
|
2024-08-15 13:55:26 +10:00
|
|
|
nativeCheckInputs = [
|
postgresql: replace pg_config with custom script
By replacing upstream's pg_config binary with a shell script, we:
- gain the ability to run pg_config easily when cross-compiling,
- can remove the fake pg_config in the default output,
- can remove the pg_config wrapper script dealing with special cases.
Some 20 years ago, pg_config *was* a shell script upstream, too. It was
changed to a binary, when it was made "relocatable", so it would return
paths depending on the location of the "postgres" binary. However, this
is exactly the thing that just hurts us in nixpkgs - we don't want those
paths to change, we want them to always point at the right outputs. By
writing the script ourselves, this becomes a lot less painful.
This approach means more lines of codes, but all of them are dead simple
and we have a lot less complexity overall.
Additionally, pg_config is now made a separate derivation, only exposed
as "postgresql.pg_config". This has the nice side-effect, that all users
of postgresql and libpq in nixpkgs must be very *explicit* about their
dependency on pg_config. This gives a lot more visibility into the state
of affairs regarding pkg-config support for libpq, which ultimately is
the much better solution.
2025-03-10 19:35:50 +01:00
|
|
|
postgresql
|
2024-08-15 13:55:26 +10:00
|
|
|
postgresqlTestHook
|
|
|
|
cunit
|
|
|
|
libxslt
|
|
|
|
];
|
2024-08-02 17:28:10 +10:00
|
|
|
|
|
|
|
postgresqlTestUserOptions = "LOGIN SUPERUSER";
|
|
|
|
|
2018-02-20 22:17:16 +01:00
|
|
|
# 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";
|
2023-11-22 18:49:33 -05:00
|
|
|
|
2024-09-17 21:55:33 +02:00
|
|
|
setOutputFlags = false;
|
2018-02-20 22:17:16 +01:00
|
|
|
preConfigure = ''
|
2024-11-15 21:44:56 +01:00
|
|
|
./autogen.sh
|
2018-02-20 22:17:16 +01:00
|
|
|
'';
|
2024-09-17 21:55:33 +02:00
|
|
|
|
|
|
|
configureFlags = [
|
postgresql: replace pg_config with custom script
By replacing upstream's pg_config binary with a shell script, we:
- gain the ability to run pg_config easily when cross-compiling,
- can remove the fake pg_config in the default output,
- can remove the pg_config wrapper script dealing with special cases.
Some 20 years ago, pg_config *was* a shell script upstream, too. It was
changed to a binary, when it was made "relocatable", so it would return
paths depending on the location of the "postgres" binary. However, this
is exactly the thing that just hurts us in nixpkgs - we don't want those
paths to change, we want them to always point at the right outputs. By
writing the script ourselves, this becomes a lot less painful.
This approach means more lines of codes, but all of them are dead simple
and we have a lot less complexity overall.
Additionally, pg_config is now made a separate derivation, only exposed
as "postgresql.pg_config". This has the nice side-effect, that all users
of postgresql and libpq in nixpkgs must be very *explicit* about their
dependency on pg_config. This gives a lot more visibility into the state
of affairs regarding pkg-config support for libpq, which ultimately is
the much better solution.
2025-03-10 19:35:50 +01:00
|
|
|
"--with-pgconfig=${postgresql.pg_config}/bin/pg_config"
|
2024-09-17 21:55:33 +02:00
|
|
|
"--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";
|
2024-09-17 21:55:33 +02:00
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"PERL=${perl}/bin/perl"
|
|
|
|
];
|
|
|
|
|
2024-08-02 17:28:10 +10:00
|
|
|
doCheck = stdenv.hostPlatform.isLinux;
|
|
|
|
|
|
|
|
preCheck = ''
|
2024-10-03 13:59:48 +02:00
|
|
|
substituteInPlace doc/postgis-out.xml --replace-fail "http://docbook.org/xml/5.0/dtd/docbook.dtd" "${docbook5}/xml/dtd/docbook/docbookx.dtd"
|
2024-08-26 14:39:19 -04:00
|
|
|
# The test suite hardcodes it to use /tmp.
|
|
|
|
export PGIS_REG_TMPDIR="$TMPDIR/pgis_reg"
|
2024-08-02 17:28:10 +10:00
|
|
|
'';
|
|
|
|
|
2019-01-26 21:15:43 +02:00
|
|
|
# create aliases for all commands adding version information
|
|
|
|
postInstall = ''
|
|
|
|
for prog in $out/bin/*; do # */
|
2024-11-01 19:32:30 +01:00
|
|
|
ln -s $prog $prog-${finalAttrs.version}
|
2019-01-26 21:15:43 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -p $doc/share/doc/postgis
|
|
|
|
mv doc/* $doc/share/doc/postgis/
|
|
|
|
'';
|
|
|
|
|
2024-11-01 19:32:30 +01:00
|
|
|
passthru.tests.extension = postgresqlTestExtension {
|
|
|
|
inherit (finalAttrs) finalPackage;
|
|
|
|
sql =
|
|
|
|
''
|
|
|
|
CREATE EXTENSION postgis;
|
|
|
|
CREATE EXTENSION postgis_raster;
|
|
|
|
CREATE EXTENSION postgis_topology;
|
|
|
|
-- 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;
|
|
|
|
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);
|
2024-11-01 19:32:30 +01:00
|
|
|
'';
|
2025-04-12 22:46:06 +02:00
|
|
|
asserts =
|
|
|
|
[
|
|
|
|
{
|
|
|
|
query = "postgis_version()";
|
|
|
|
expected = "'${lib.versions.major finalAttrs.version}.${lib.versions.minor finalAttrs.version} USE_GEOS=1 USE_PROJ=1 USE_STATS=1'";
|
|
|
|
description = "postgis_version() returns correct values.";
|
|
|
|
}
|
|
|
|
]
|
|
|
|
++ lib.optional withSfcgal {
|
|
|
|
query = "postgis_sfcgal_version()";
|
|
|
|
expected = "'${sfcgal.version}'";
|
|
|
|
description = "postgis_sfcgal_version() returns correct value.";
|
|
|
|
};
|
2024-11-01 19:32:30 +01:00
|
|
|
};
|
2020-11-21 04:20:00 +00:00
|
|
|
|
2025-03-16 21:00:42 +01:00
|
|
|
meta = {
|
2018-02-20 22:17:16 +01:00
|
|
|
description = "Geographic Objects for PostgreSQL";
|
2020-03-31 21:11:51 -04:00
|
|
|
homepage = "https://postgis.net/";
|
2024-11-01 19:32:30 +01:00
|
|
|
changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${finalAttrs.version}/NEWS";
|
2025-03-16 21:00:42 +01:00
|
|
|
license = lib.licenses.gpl2Plus;
|
|
|
|
maintainers = with lib.maintainers; [ marcweber ];
|
|
|
|
teams = [ lib.teams.geospatial ];
|
2019-08-01 08:21:07 +10:00
|
|
|
inherit (postgresql.meta) platforms;
|
2018-02-20 22:17:16 +01:00
|
|
|
};
|
2024-11-01 19:32:30 +01:00
|
|
|
})
|