@@ -1,6 +1,6 @@
11{ stdenv, fetchurl, gmp, readline, openssl, libjpeg, unixODBC, zlib
22, libXinerama, libXft, libXpm, libSM, libXt, freetype, pkgconfig
3−, fontconfig
3+, fontconfig, makeWrapper ? stdenv.isDarwin
44}:
55
66let
@@ -15,7 +15,8 @@ stdenv.mkDerivation {
1515 };
1616
1717 buildInputs = [ gmp readline openssl libjpeg unixODBC libXinerama
18− libXft libXpm libSM libXt zlib freetype pkgconfig fontconfig ];
18+ libXft libXpm libSM libXt zlib freetype pkgconfig fontconfig ]
19+ ++ stdenv.lib.optional stdenv.isDarwin makeWrapper;
1920
2021 hardeningDisable = [ "format" ];
2122
@@ -23,12 +24,24 @@ stdenv.mkDerivation {
2324
2425 buildFlags = "world";
2526
27+ # For macOS: still not fixed in upstream: "abort trap 6" when called
28+ # through symlink, so wrap binary.
29+ # We reinvent wrapProgram here but omit argv0 pass in order to not
30+ # break PAKCS package build. This is also safe for SWI-Prolog, since
31+ # there is no wrapping environment and hence no need to spoof $0
32+ postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
33+ local prog="$out/bin/swipl"
34+ local hidden="$(dirname "$prog")/.$(basename "$prog")"-wrapped
35+ mv $prog $hidden
36+ makeWrapper $hidden $prog
37+ '';
38+
2639 meta = {
2740 homepage = http://www.swi-prolog.org/;
2841 description = "A Prolog compiler and interpreter";
2942 license = "LGPL";
3043
31− platforms = stdenv.lib.platforms.linux;
44+ platforms = stdenv.lib.platforms.unix;
3245 maintainers = [ stdenv.lib.maintainers.peti ];
3346 };
3447}