swi-prolog: updated version + packs support

Using "extraPacks" and "extraLibraries" arguments
it is possible to create fully functional virtual-envs
for SWI-Prolog projects.
(In a way similar to what "ghcWithPackages" does for Haskell)
This commit is contained in:
Barak Bercovitz 2019-04-25 17:25:19 +03:00
parent 5d2775156b
commit 990acf7025

View file

@ -1,22 +1,30 @@
{ stdenv, fetchurl, jdk, gmp, readline, openssl, libjpeg, unixODBC, zlib
{ stdenv, fetchgit, jdk, gmp, readline, openssl, libjpeg, unixODBC, zlib
, libXinerama, libarchive, db, pcre, libedit, libossp_uuid, libXft, libXpm
, libSM, libXt, freetype, pkgconfig, fontconfig, makeWrapper ? stdenv.isDarwin
, git, cacert, cmake, libyaml
, extraLibraries ? [ jdk unixODBC libXpm libSM libXt freetype fontconfig ]
, extraPacks ? []
}:
let
version = "7.6.4";
version = "8.1.4";
packInstall = swiplPath: pack:
''${swiplPath}/bin/swipl -g "pack_install(${pack}, [package_directory(\"${swiplPath}/lib/swipl/pack\"), silent(true), interactive(false)])." -t "halt."
'';
in
stdenv.mkDerivation {
name = "swi-prolog-${version}";
src = fetchurl {
url = "http://www.swi-prolog.org/download/stable/src/swipl-${version}.tar.gz";
sha256 = "14bq4sqs61maqpnmgy6687jjj0shwc27cpfsqbf056nrssmplg9d";
src = fetchgit {
url = "https://github.com/SWI-Prolog/swipl-devel";
rev = "V${version}";
sha256 = "0qxa6f5dypwczxajlf0l736adbjb17cbak3qsh5g04hpv2bxm6dh";
};
buildInputs = [ jdk gmp readline openssl libjpeg unixODBC libXinerama
libarchive db pcre libedit libossp_uuid libXft libXpm libSM libXt
zlib freetype pkgconfig fontconfig ]
buildInputs = [ cacert git cmake gmp readline openssl
libarchive libyaml db pcre libedit libossp_uuid
zlib pkgconfig ]
++ extraLibraries
++ stdenv.lib.optional stdenv.isDarwin makeWrapper;
hardeningDisable = [ "format" ];
@ -27,7 +35,20 @@ stdenv.mkDerivation {
"--enable-shared"
];
buildFlags = "world";
installPhase = ''
mkdir -p $out
mkdir build
cd build
${cmake}/bin/cmake -DCMAKE_INSTALL_PREFIX=$out ..
cd ../
make
make install
make clean
mkdir -p $out/lib/swipl/pack
''
+ builtins.concatStringsSep "\n"
( builtins.map (packInstall "$out") extraPacks
);
# For macOS: still not fixed in upstream: "abort trap 6" when called
# through symlink, so wrap binary.