2015-11-16 20:53:39 +01:00
|
|
|
{ stdenv, fetchgit, fetchurl, python, makeWrapper, pkgconfig, gcc,
|
|
|
|
pypy, libffi, libedit, libuv, boost, zlib,
|
|
|
|
variant ? "jit", buildWithPypy ? false }:
|
|
|
|
|
|
|
|
let
|
2016-08-17 22:10:40 +02:00
|
|
|
commit-count = "1356";
|
2015-11-16 20:53:39 +01: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";
|
2016-08-17 22:10:40 +02:00
|
|
|
rev = "d2a4267ea088f711af36a74928e8dfd8360584ad";
|
|
|
|
sha256 = "1asf6yx7zy9cx4bsg8iai57dy3r3m45xcmkmw2vix70xvfy23ryf";
|
2015-11-16 20:53:39 +01:00
|
|
|
};
|
2016-08-17 22:10:40 +02:00
|
|
|
pypy-tag = "91db1a9";
|
2015-11-16 20:53:39 +01:00
|
|
|
pypy-src = fetchurl {
|
|
|
|
name = "pypy-src-${pypy-tag}";
|
|
|
|
url = "https://bitbucket.org/pypy/pypy/get/${pypy-tag}.tar.bz2";
|
2016-08-17 22:10:40 +02:00
|
|
|
sha256 = "0ylbqvhbcp5m09l15i2q2h3a0vjd055x2r37cq71lkhgmmaxrwbq";
|
2015-11-16 20:53:39 +01:00
|
|
|
};
|
2016-04-27 23:41:28 +02:00
|
|
|
libs = [ libffi libedit libuv boost.dev boost.out zlib ];
|
2015-11-16 20:53:39 +01: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}";
|
|
|
|
nativeBuildInputs = libs;
|
|
|
|
buildInputs = [ pkgconfig makeWrapper ];
|
|
|
|
PYTHON = if buildWithPypy
|
|
|
|
then "${pypy}/pypy-c/.pypy-c-wrapped"
|
|
|
|
else "${python}/bin/python";
|
|
|
|
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 19:50:01 +02:00
|
|
|
libraryPaths='["${libuv}" "${libedit}" "${libffi.dev}" "${boost.dev}" "${boost.out}" "${zlib.dev}"]'
|
2015-11-16 20:53:39 +01: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}
|
|
|
|
export LD_LIBRARY_PATH="${library-path}:$LD_LIBRARY_PATH"
|
|
|
|
find pixie -name "*.pxi" -exec ./pixie-vm -c {} \;
|
|
|
|
)'';
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/share $out/bin
|
|
|
|
cp pixie-src/pixie-vm $out/share/pixie-vm
|
|
|
|
cp -R pixie-src/pixie $out/share/pixie
|
2016-08-19 02:31:18 +02:00
|
|
|
makeWrapper $out/share/pixie-vm $out/bin/pixie-vm \
|
2015-11-16 20:53:39 +01:00
|
|
|
--prefix LD_LIBRARY_PATH : ${library-path} \
|
|
|
|
--prefix C_INCLUDE_PATH : ${include-path} \
|
|
|
|
--prefix LIBRARY_PATH : ${library-path} \
|
|
|
|
--prefix PATH : ${bin-path}
|
2016-08-19 02:31:18 +02:00
|
|
|
cat > $out/bin/pxi <<EOF
|
|
|
|
#!$shell
|
|
|
|
>&2 echo "[\$\$] WARNING: 'pxi' is a deprecated alias for 'pixie-vm', please update your scripts."
|
|
|
|
exec $out/bin/pixie-vm "\$@"
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/pxi
|
2015-11-16 20:53:39 +01:00
|
|
|
'';
|
|
|
|
meta = {
|
2016-03-06 14:04:37 +01:00
|
|
|
description = "A clojure-like lisp, built with the pypy vm toolkit";
|
2015-11-16 20:53:39 +01:00
|
|
|
homepage = "https://github.com/pixie-lang/pixie";
|
|
|
|
license = stdenv.lib.licenses.lgpl3;
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in build (builtins.getAttr variant variants)
|