2016-11-09 15:14:48 +00:00
|
|
|
{ stdenv, fetchgit, fetchurl, python2, makeWrapper, pkgconfig, gcc,
|
2015-11-16 19:53:39 +00:00
|
|
|
pypy, libffi, libedit, libuv, boost, zlib,
|
|
|
|
variant ? "jit", buildWithPypy ? false }:
|
|
|
|
|
|
|
|
let
|
2017-08-01 16:12:35 +01:00
|
|
|
commit-count = "1364";
|
2015-11-16 19:53:39 +00:00
|
|
|
common-flags = "--thread --gcrootfinder=shadowstack --continuation";
|
|
|
|
variants = {
|
|
|
|
jit = { flags = "--opt=jit"; target = "target.py"; };
|
|
|
|
jit-preload = { flags = "--opt=jit"; target = "target_preload.py"; };
|
|
|
|
no-jit = { flags = ""; target = "target.py"; };
|
|
|
|
no-jit-preload = { flags = ""; target = "target_preload.py"; };
|
|
|
|
};
|
|
|
|
pixie-src = fetchgit {
|
|
|
|
url = "https://github.com/pixie-lang/pixie.git";
|
2017-08-01 16:12:35 +01:00
|
|
|
rev = "5eb0ccbe8b0087d3a5f2d0bbbc6998d624d3cd62";
|
|
|
|
sha256 = "0pf31x5h2m6dpxlidv98qay1y179qw40cw4cb4v4xa88gmq2f3vm";
|
2015-11-16 19:53:39 +00:00
|
|
|
};
|
2016-08-17 21:10:40 +01:00
|
|
|
pypy-tag = "91db1a9";
|
2015-11-16 19:53:39 +00:00
|
|
|
pypy-src = fetchurl {
|
|
|
|
name = "pypy-src-${pypy-tag}";
|
|
|
|
url = "https://bitbucket.org/pypy/pypy/get/${pypy-tag}.tar.bz2";
|
2016-08-17 21:10:40 +01:00
|
|
|
sha256 = "0ylbqvhbcp5m09l15i2q2h3a0vjd055x2r37cq71lkhgmmaxrwbq";
|
2015-11-16 19:53:39 +00:00
|
|
|
};
|
2016-04-27 22:41:28 +01:00
|
|
|
libs = [ libffi libedit libuv boost.dev boost.out zlib ];
|
2015-11-16 19:53:39 +00:00
|
|
|
include-path = stdenv.lib.concatStringsSep ":"
|
|
|
|
(map (p: "${p}/include") libs);
|
|
|
|
library-path = stdenv.lib.concatStringsSep ":"
|
|
|
|
(map (p: "${p}/lib") libs);
|
|
|
|
bin-path = stdenv.lib.concatStringsSep ":"
|
|
|
|
(map (p: "${p}/bin") [ gcc ]);
|
|
|
|
build = {flags, target}: stdenv.mkDerivation rec {
|
|
|
|
name = "pixie-${version}";
|
|
|
|
version = "0-r${commit-count}-${variant}";
|
2017-09-05 23:03:42 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper pkgconfig ];
|
|
|
|
buildInputs = libs;
|
2015-11-16 19:53:39 +00:00
|
|
|
PYTHON = if buildWithPypy
|
2019-01-31 18:51:23 +00:00
|
|
|
then "${pypy}/pypy-c/pypy-c"
|
2016-11-09 15:14:48 +00:00
|
|
|
else "${python2.interpreter}";
|
2015-11-16 19:53:39 +00:00
|
|
|
unpackPhase = ''
|
|
|
|
cp -R ${pixie-src} pixie-src
|
|
|
|
mkdir pypy-src
|
|
|
|
(cd pypy-src
|
|
|
|
tar --strip-components=1 -xjf ${pypy-src})
|
|
|
|
chmod -R +w pypy-src pixie-src
|
|
|
|
'';
|
|
|
|
patchPhase = ''
|
|
|
|
(cd pixie-src
|
|
|
|
patch -p1 < ${./load_paths.patch}
|
2016-04-16 18:50:01 +01:00
|
|
|
libraryPaths='["${libuv}" "${libedit}" "${libffi.dev}" "${boost.dev}" "${boost.out}" "${zlib.dev}"]'
|
2015-11-16 19:53:39 +00:00
|
|
|
export libraryPaths
|
|
|
|
substituteAllInPlace ./pixie/ffi-infer.pxi)
|
|
|
|
'';
|
|
|
|
buildPhase = ''(
|
|
|
|
PYTHONPATH="`pwd`/pypy-src:$PYTHONPATH";
|
|
|
|
RPYTHON="`pwd`/pypy-src/rpython/bin/rpython";
|
|
|
|
cd pixie-src
|
|
|
|
$PYTHON $RPYTHON ${common-flags} ${target}
|
|
|
|
find pixie -name "*.pxi" -exec ./pixie-vm -c {} \;
|
|
|
|
)'';
|
2018-01-30 23:44:32 +00:00
|
|
|
LD_LIBRARY_PATH = library-path;
|
|
|
|
C_INCLUDE_PATH = include-path;
|
|
|
|
LIBRARY_PATH = library-path;
|
|
|
|
PATH = bin-path;
|
2015-11-16 19:53:39 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share $out/bin
|
|
|
|
cp pixie-src/pixie-vm $out/share/pixie-vm
|
|
|
|
cp -R pixie-src/pixie $out/share/pixie
|
2018-01-12 05:03:25 +00:00
|
|
|
makeWrapper $out/share/pixie-vm $out/bin/pixie \
|
2018-01-30 23:44:32 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : ${LD_LIBRARY_PATH} \
|
|
|
|
--prefix C_INCLUDE_PATH : ${C_INCLUDE_PATH} \
|
|
|
|
--prefix LIBRARY_PATH : ${LIBRARY_PATH} \
|
|
|
|
--prefix PATH : ${PATH}
|
|
|
|
'';
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
RES=$(./pixie-src/pixie-vm -e "(print :ok)")
|
|
|
|
if [ "$RES" != ":ok" ]; then
|
|
|
|
echo "ERROR Unexpected output: '$RES'"
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
echo "$RES"
|
|
|
|
fi
|
2015-11-16 19:53:39 +00:00
|
|
|
'';
|
|
|
|
meta = {
|
2016-03-06 13:04:37 +00:00
|
|
|
description = "A clojure-like lisp, built with the pypy vm toolkit";
|
2017-08-01 21:03:30 +01:00
|
|
|
homepage = https://github.com/pixie-lang/pixie;
|
2015-11-16 19:53:39 +00:00
|
|
|
license = stdenv.lib.licenses.lgpl3;
|
2018-01-12 05:03:25 +00:00
|
|
|
platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
|
2017-10-29 01:05:07 +01:00
|
|
|
maintainers = with stdenv.lib.maintainers; [ bendlas ];
|
2015-11-16 19:53:39 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
in build (builtins.getAttr variant variants)
|