Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgis: allow on Darwin #65460

Merged
merged 4 commits into from Aug 3, 2019
Merged

postgis: allow on Darwin #65460

merged 4 commits into from Aug 3, 2019

Conversation

lrworth
Copy link
Contributor

@lrworth lrworth commented Jul 27, 2019

Resolves #65452.

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; viz.

  cc x -bundle_loader $POSTGIS_PREFIX/bin/postgres

The bundle_loader parameter is only available on Darwin ld, 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.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

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.
@vcunat
Copy link
Member

vcunat commented Jul 27, 2019

@GrahamcOfBorg build postgis

@lrworth
Copy link
Contributor Author

lrworth commented Jul 27, 2019

gdal doesn't build with sandbox enabled. I don't know how to debug this problem right now.

@vcunat
Copy link
Member

vcunat commented Jul 27, 2019

Borg's build did succeed on Darwin. I actually don't remember what's status of the Darwin sandbox. I assume further improvements can be left for later (in any case I'd leave some time for others to react).

pkgs/servers/sql/postgresql/ext/postgis.nix Show resolved Hide resolved
'';

# create aliases for all commands adding version information
postInstall = ''
rm $out/bin/postgres
for prog in $out/bin/*; do # */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this is not a change in this PR, do you know why there's a */ comment here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That clearly seems to unbreak syntax highlighting in editors that get confused by /* on that same line. One can see similar ones all over nixpkgs.

@kalbasit
Copy link
Member

kalbasit commented Aug 1, 2019

@GrahamcOfBorg build postgis

ysndr pushed a commit to ysndr/nixpkgs that referenced this pull request Aug 3, 2019
@vcunat vcunat merged commit c1da476 into NixOS:master Aug 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

postgis: support macOS
5 participants