From 330fff02a675f389f429d872a590ed65fc93aedb Mon Sep 17 00:00:00 2001 From: Luke Worth Date: Sat, 27 Jul 2019 17:06:18 +1000 Subject: [PATCH 1/4] postgis: allow on Darwin To get PostGIS going on Darwin: 1. Add libiconv, as is often required. 2. Expand platforms to `platforms.all`. 3. Deal with PostGIS' quirky build system. PostGIS' configure.ac has the following gem: AC_MSG_RESULT([------------------------------------------------------------------------]) AC_MSG_RESULT([ WARNING: You have set the --prefix to '$prefix'. But we mostly ]) AC_MSG_RESULT([ ignore the --prefix. For your info, using the values determined from ]) AC_MSG_RESULT([ $PG_CONFIG we will be installing: ]) AC_MSG_RESULT([ * postgis shared library in $PGSQL_LIBDIR ]) AC_MSG_RESULT([ * postgis SQL files in $PGSQL_SHAREDIR/contrib/postgis-$POSTGIS_MAJOR_VERSION.$POSTGIS_MINOR_VERSION ]) AC_MSG_RESULT([ * postgis executables in $PGSQL_BINDIR ]) AC_MSG_RESULT([------------------------------------------------------------------------]) This is suggestive of some assumptions in the build system, which are revealed when building in Nix on Darwin: the build fails because the postgres binary cannot be found in the install prefix specified for postgis; vis. cc x -bundle_loader $POSTGIS_PREFIX/bin/postgres This bundle_loader parameter is only available on Darwin, and this problem doesn't appear to affect Linux systems. The solution presented here is to symlink the postgres binary where PostGIS expects it to be, and then remove it after the build completes. --- pkgs/servers/sql/postgresql/ext/postgis.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkgs/servers/sql/postgresql/ext/postgis.nix b/pkgs/servers/sql/postgresql/ext/postgis.nix index de9d7eb1305..81fbd41b46a 100644 --- a/pkgs/servers/sql/postgresql/ext/postgis.nix +++ b/pkgs/servers/sql/postgresql/ext/postgis.nix @@ -10,6 +10,7 @@ , pkgconfig , file , protobufc +, libiconv }: stdenv.mkDerivation rec { name = "postgis-${version}"; @@ -22,7 +23,7 @@ stdenv.mkDerivation rec { sha256 = "0pnva72f2w4jcgnl1y7nw5rdly4ipx3hji4c9yc9s0hna1n2ijxn"; }; - buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc ]; + buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc libiconv ]; nativeBuildInputs = [ perl pkgconfig ]; dontDisableStatic = true; @@ -43,14 +44,13 @@ stdenv.mkDerivation rec { sed -i "s|\$(DESTDIR)\$(PGSQL_BINDIR)|$prefix/bin|g " \ "raster/scripts/python/Makefile"; - ''; - - preInstall = '' mkdir -p $out/bin + ln -s ${postgresql}/bin/postgres $out/bin/postgres ''; # create aliases for all commands adding version information postInstall = '' + rm $out/bin/postgres for prog in $out/bin/*; do # */ ln -s $prog $prog-${version} done @@ -64,6 +64,6 @@ stdenv.mkDerivation rec { homepage = https://postgis.net/; license = licenses.gpl2; maintainers = [ maintainers.marcweber ]; - platforms = platforms.linux; + platforms = platforms.all; }; } From 7f54b9a2c6f7ac61bcd9f7f8788cd4475b729bd6 Mon Sep 17 00:00:00 2001 From: Luke Worth Date: Sat, 27 Jul 2019 19:43:31 +1000 Subject: [PATCH 2/4] postgis: make libiconv dependent on darwin --- pkgs/servers/sql/postgresql/ext/postgis.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/servers/sql/postgresql/ext/postgis.nix b/pkgs/servers/sql/postgresql/ext/postgis.nix index 81fbd41b46a..5e38cb42d19 100644 --- a/pkgs/servers/sql/postgresql/ext/postgis.nix +++ b/pkgs/servers/sql/postgresql/ext/postgis.nix @@ -23,7 +23,8 @@ stdenv.mkDerivation rec { sha256 = "0pnva72f2w4jcgnl1y7nw5rdly4ipx3hji4c9yc9s0hna1n2ijxn"; }; - buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc libiconv ]; + buildInputs = [ libxml2 postgresql geos proj gdal json_c protobufc ] + ++ stdenv.lib.optional stdenv.isDarwin libiconv; nativeBuildInputs = [ perl pkgconfig ]; dontDisableStatic = true; From 19011bad0c512c42f68f1ed589df36ab66cf8ef6 Mon Sep 17 00:00:00 2001 From: Luke Worth Date: Thu, 1 Aug 2019 08:16:59 +1000 Subject: [PATCH 3/4] postgis: add explanatory comment --- pkgs/servers/sql/postgresql/ext/postgis.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/servers/sql/postgresql/ext/postgis.nix b/pkgs/servers/sql/postgresql/ext/postgis.nix index 5e38cb42d19..aa31d3163c8 100644 --- a/pkgs/servers/sql/postgresql/ext/postgis.nix +++ b/pkgs/servers/sql/postgresql/ext/postgis.nix @@ -46,12 +46,17 @@ stdenv.mkDerivation rec { " \ "raster/scripts/python/Makefile"; mkdir -p $out/bin + + # postgis' build system assumes it is being installed to the same place as postgresql, and looks + # for the postgres binary relative to $PREFIX. We gently support this system using an illusion. ln -s ${postgresql}/bin/postgres $out/bin/postgres ''; # create aliases for all commands adding version information postInstall = '' + # Teardown the illusory postgres used for building; see postConfigure. rm $out/bin/postgres + for prog in $out/bin/*; do # */ ln -s $prog $prog-${version} done From c1da476a8815bb9c618e78bd85d54f8825f788b7 Mon Sep 17 00:00:00 2001 From: Luke Worth Date: Thu, 1 Aug 2019 08:21:07 +1000 Subject: [PATCH 4/4] postgis: match platform compatibility with postgres --- pkgs/servers/sql/postgresql/ext/postgis.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/sql/postgresql/ext/postgis.nix b/pkgs/servers/sql/postgresql/ext/postgis.nix index aa31d3163c8..63b8a39b0e2 100644 --- a/pkgs/servers/sql/postgresql/ext/postgis.nix +++ b/pkgs/servers/sql/postgresql/ext/postgis.nix @@ -70,6 +70,6 @@ stdenv.mkDerivation rec { homepage = https://postgis.net/; license = licenses.gpl2; maintainers = [ maintainers.marcweber ]; - platforms = platforms.all; + inherit (postgresql.meta) platforms; }; }