Skip to content

Commit 6d6dbd3

Browse files
authored
feat: postgis built in our bundle again and matching version we need (#954)
1 parent 73f1d9c commit 6d6dbd3

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

flake.nix

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
# want to have an arbitrary order, since it might matter. being
5252
# explicit is better.
5353
(import ./nix/overlays/cargo-pgrx-0-11-3.nix)
54+
# (import ./nix/overlays/postgis.nix)
5455
#(import ./nix/overlays/gdal-small.nix)
5556

5657
];
@@ -78,7 +79,7 @@
7879
# may also bring in new versions of the extensions.
7980
psqlExtensions = [
8081
/* pljava */
81-
"postgis"
82+
/*"postgis"*/
8283
];
8384

8485
#FIXME for now, timescaledb is not included in the orioledb version of supabase extensions, as there is an issue
@@ -108,7 +109,7 @@
108109
./nix/ext/plpgsql-check.nix
109110
./nix/ext/pgjwt.nix
110111
./nix/ext/pgaudit.nix
111-
#./nix/ext/postgis.nix
112+
./nix/ext/postgis.nix
112113
./nix/ext/pgrouting.nix
113114
./nix/ext/pgtap.nix
114115
./nix/ext/pg_cron.nix
@@ -135,7 +136,7 @@
135136

136137
#this var is a convenience setting to import the orioledb patched version of postgresql
137138
postgresql_orioledb_16 = oriole_pkgs.postgresql_orioledb_16;
138-
postgis_override = pkgs.postgis_override;
139+
#postgis_override = pkgs.postgis_override;
139140

140141
# Create a 'receipt' file for a given postgresql package. This is a way
141142
# of adding a bit of metadata to the package, which can be used by other

nix/ext/postgis.nix

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,44 @@
55
, postgresql
66
, geos
77
, proj
8-
, gdal
8+
, gdalMinimal
99
, json_c
1010
, pkg-config
1111
, file
1212
, protobufc
1313
, libiconv
14+
, pcre2
1415
, nixosTests
1516
}:
17+
18+
let
19+
gdal = gdalMinimal;
20+
in
1621
stdenv.mkDerivation rec {
1722
pname = "postgis";
1823
version = "3.3.2";
1924

2025
outputs = [ "out" "doc" ];
2126

22-
src = fetchurl {
27+
src = fetchurl {
2328
url = "https://download.osgeo.org/postgis/source/postgis-${version}.tar.gz";
2429
sha256 = "sha256-miohnaAFoXMKOdGVmhx87GGbHvsAm2W+gP/CW60pkGg=";
2530
};
2631

27-
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc ]
32+
buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc pcre2.dev ]
2833
++ lib.optional stdenv.isDarwin libiconv;
29-
nativeBuildInputs = [ perl pkg-config ] ++ lib.optional postgresql.jitSupport postgresql.llvm;
34+
nativeBuildInputs = [ perl pkg-config ];
3035
dontDisableStatic = true;
3136

3237
# postgis config directory assumes /include /lib from the same root for json-c library
33-
NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";
38+
env.NIX_LDFLAGS = "-L${lib.getLib json_c}/lib";
39+
3440

3541
preConfigure = ''
3642
sed -i 's@/usr/bin/file@${file}/bin/file@' configure
37-
configureFlags="--datadir=$out/share/postgresql --datarootdir=$out/share/postgresql --bindir=$out/bin --with-gdalconfig=${gdal}/bin/gdal-config --with-jsondir=${json_c.dev}"
43+
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"
3844
39-
makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin"
45+
makeFlags="PERL=${perl}/bin/perl datadir=$out/share/postgresql pkglibdir=$out/lib bindir=$out/bin docdir=$doc/share/doc/${pname}"
4046
'';
4147
postConfigure = ''
4248
sed -i "s|@mkdir -p \$(DESTDIR)\$(PGSQL_BINDIR)||g ;
@@ -50,7 +56,7 @@ stdenv.mkDerivation rec {
5056
5157
# postgis' build system assumes it is being installed to the same place as postgresql, and looks
5258
# for the postgres binary relative to $PREFIX. We gently support this system using an illusion.
53-
ln -s ${postgresql_15}/bin/postgres $out/bin/postgres
59+
ln -s ${postgresql}/bin/postgres $out/bin/postgres
5460
'';
5561

5662
# create aliases for all commands adding version information
@@ -73,7 +79,7 @@ stdenv.mkDerivation rec {
7379
homepage = "https://postgis.net/";
7480
changelog = "https://git.osgeo.org/gitea/postgis/postgis/raw/tag/${version}/NEWS";
7581
license = licenses.gpl2;
76-
maintainers = [ samrose ];
82+
maintainers = with maintainers; teams.geospatial.members ++ [ marcweber wolfgangwalther ];
7783
inherit (postgresql.meta) platforms;
7884
};
7985
}

nix/overlays/postgis.nix

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
final: prev: {
2+
postgis = prev.postgresqlPackages.postgis.overrideAttrs (old: {
3+
version = "3.3.2";
4+
sha256 = "";
5+
});
6+
postgresqlPackages.postgis = final.postgis;
7+
}

0 commit comments

Comments
 (0)