nixpkgs/pkgs/development/compilers/swi-prolog/default.nix

89 lines
3.0 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitHub, jdk, gmp, readline, openssl, unixODBC, zlib
, libarchive, db, pcre, libedit, libossp_uuid, libXpm
, libSM, libXt, freetype, pkg-config, fontconfig
2019-10-15 03:30:00 +00:00
, cmake, libyaml, Security
, libjpeg, libX11, libXext, libXft, libXinerama
, extraLibraries ? [ jdk unixODBC libXpm libSM libXt freetype fontconfig ]
# Packs must be installed from a local directory during the build, with dependencies
# resolved manually, e.g. to install the 'julian' pack, which depends on the 'delay', 'list_util' and 'typedef' packs:
# julian = pkgs.fetchzip {
# name = "swipl-pack-julian";
# url = "https://github.com/mndrix/julian/archive/v0.1.3.zip";
# sha256 = "1sgql7c21p3c5m14kwa0bcmlwn9fql612krn9h36gla1j9yjdfgy";
# };
# delay = pkgs.fetchzip {
# name = "swipl-pack-delay";
# url = "https://github.com/mndrix/delay/archive/v0.3.3.zip";
# sha256 = "0ira87afxnc2dnbbmgwmrr8qvary8lhzvhqwd52dccm6yqd3nybg";
# };
# list_util = pkgs.fetchzip {
# name = "swipl-pack-list_util";
# url = "https://github.com/mndrix/list_util/archive/v0.13.0.zip";
# sha256 = "0lx7vffflak0y8l8vg8k0g8qddwwn23ksbz02hi3f8rbarh1n89q";
# };
# typedef = builtins.fetchTarball {
# name = "swipl-pack-typedef";
# url = "https://raw.githubusercontent.com/samer--/prolog/master/typedef/release/typedef-0.1.9.tgz";
# sha256 = "056nqjn01g18fb1b2qivv9s7hb4azk24nx2d4kvkbmm1k91f44p3";
# };
# swiProlog = pkgs.swiProlog.override { extraPacks = map (dep-path: "'file://${dep-path}'") [
# julian delay list_util typedef
# ]; };
, extraPacks ? []
, withGui ? false
2014-01-13 16:10:11 +00:00
}:
let
2020-10-15 15:25:55 +00:00
version = "8.3.9";
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 {
2019-08-13 21:52:01 +00:00
pname = "swi-prolog";
inherit version;
2019-10-15 03:30:00 +00:00
src = fetchFromGitHub {
owner = "SWI-Prolog";
repo = "swipl-devel";
rev = "V${version}";
2020-10-15 15:25:55 +00:00
sha256 = "0ixb8pc5s7q8q0njs8is1clpvik6jhhdcwnys7m9rpwdzgi10sjz";
2019-10-15 03:30:00 +00:00
fetchSubmodules = true;
};
# Add the packInstall path to the swipl pack search path
postPatch = ''
2021-05-11 19:10:57 +00:00
echo "user:file_search_path(pack, '$out/lib/swipl/pack')." >> boot/init.pl
'';
nativeBuildInputs = [ cmake pkg-config ];
2019-10-15 03:30:00 +00:00
buildInputs = [ gmp readline openssl
libarchive libyaml db pcre libedit libossp_uuid
2019-10-15 03:30:00 +00:00
zlib ]
++ lib.optionals (withGui && !stdenv.isDarwin) [ libXpm libX11 libXext libXft libXinerama libjpeg ]
++ extraLibraries
++ lib.optional stdenv.isDarwin Security;
2014-01-13 16:10:11 +00:00
hardeningDisable = [ "format" ];
2016-02-24 17:10:58 +00:00
2019-10-15 03:30:00 +00:00
cmakeFlags = [ "-DSWIPL_INSTALL_IN_LIB=ON" ];
2014-01-13 16:10:11 +00:00
preInstall = ''
mkdir -p $out/lib/swipl/pack
'';
2019-10-15 03:30:00 +00:00
postInstall = builtins.concatStringsSep "\n"
( builtins.map (packInstall "$out") extraPacks
);
meta = {
2019-10-15 03:30:00 +00:00
homepage = "https://www.swi-prolog.org";
description = "A Prolog compiler and interpreter";
license = lib.licenses.bsd2;
platforms = lib.platforms.linux ++ lib.optionals (!withGui) lib.platforms.darwin;
maintainers = [ lib.maintainers.meditans ];
};
}