Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchFromGitHub, readline, openssl, libffi, valgrind, withThread ? true, withSSL ? true, xxd }:
2
3stdenv.mkDerivation rec {
4 pname = "trealla";
5 version = "2.8.6";
6
7 src = fetchFromGitHub {
8 owner = "trealla-prolog";
9 repo = "trealla";
10 rev = "v${version}";
11 sha256 = "sha256-0sAPexGKriaJVhBDRsopRYD8xrJAaXZiscCcwfWdEgQ=";
12 };
13
14 postPatch = ''
15 substituteInPlace Makefile \
16 --replace '-I/usr/local/include' "" \
17 --replace '-L/usr/local/lib' "" \
18 --replace 'GIT_VERSION :=' 'GIT_VERSION ?='
19 '';
20
21 makeFlags = [
22 "GIT_VERSION=\"v${version}\""
23 (lib.optionalString withThread "THREADS=1")
24 (lib.optionalString (!withSSL) "NOSSL=1")
25 (lib.optionalString stdenv.isDarwin "NOLDLIBS=1")
26 ];
27
28 nativeBuildInputs = [ xxd ];
29 buildInputs = [ readline openssl libffi ];
30 checkInputs = lib.optionals (!(stdenv.isDarwin && stdenv.isAarch64)) [ valgrind ];
31 enableParallelBuilding = true;
32
33 installPhase = ''
34 install -Dm755 -t $out/bin tpl
35 '';
36
37 doCheck = true;
38 preCheck = ''
39 # Disable tests due to floating point error
40 rm tests/issues-OLD/test081.pl
41 rm tests/issues-OLD/test585.pl
42 # Disable test due to Unicode issues
43 rm tests/issues-OLD/test252.pl
44 '';
45
46 meta = with lib; {
47 description = "A compact, efficient Prolog interpreter written in ANSI C";
48 homepage = "https://github.com/trealla-prolog/trealla";
49 license = licenses.mit;
50 maintainers = with maintainers; [ siraben ];
51 mainProgram = "tpl";
52 platforms = platforms.all;
53 };
54}