2021-01-22 12:25:31 +01:00
|
|
|
{ lib, stdenv, fetchurl, fetchFromGitHub
|
2019-09-19 04:44:55 +02:00
|
|
|
, llvmPackages, ncurses, lua
|
|
|
|
}:
|
2016-06-15 01:37:37 +02:00
|
|
|
|
|
|
|
let
|
2018-12-21 12:57:16 +01:00
|
|
|
luajitArchive = "LuaJIT-2.0.5.tar.gz";
|
2016-06-15 01:37:37 +02:00
|
|
|
luajitSrc = fetchurl {
|
2019-09-19 05:13:18 +02:00
|
|
|
url = "http://luajit.org/download/${luajitArchive}";
|
2018-12-21 12:57:16 +01:00
|
|
|
sha256 = "0yg9q4q6v028bgh85317ykc9whgxgysp76qzaqgq55y6jy11yjw7";
|
2016-06-15 01:37:37 +02:00
|
|
|
};
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-09-19 05:13:18 +02:00
|
|
|
pname = "terra";
|
|
|
|
version = "1.0.0pre1175_${builtins.substring 0 7 src.rev}";
|
2016-01-18 01:50:10 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2019-09-19 05:13:18 +02:00
|
|
|
owner = "zdevito";
|
|
|
|
repo = "terra";
|
|
|
|
rev = "ef6a75ffee15a30f3c74f4e6943851cfbc0fec3d";
|
|
|
|
sha256 = "0aky17vbv3d9zng34hp17p9zb00dbzwhvzsdjzrrqvk9lmyvix0s";
|
2016-01-18 01:50:10 +01:00
|
|
|
};
|
|
|
|
|
2019-09-19 07:26:48 +02:00
|
|
|
nativeBuildInputs = [ lua ];
|
|
|
|
buildInputs = with llvmPackages; [ llvm clang-unwrapped ncurses ];
|
2019-09-19 05:13:18 +02:00
|
|
|
|
2019-09-19 07:26:48 +02:00
|
|
|
doCheck = true;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
hardeningDisable = [ "fortify" ];
|
2016-08-29 02:30:01 +02:00
|
|
|
outputs = [ "bin" "dev" "out" "static" ];
|
2016-06-15 01:37:37 +02:00
|
|
|
|
2019-09-19 04:44:55 +02:00
|
|
|
patches = [ ./nix-cflags.patch ];
|
2016-06-15 01:37:37 +02:00
|
|
|
postPatch = ''
|
2019-09-19 07:26:48 +02:00
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace '-lcurses' '-lncurses'
|
|
|
|
|
|
|
|
substituteInPlace src/terralib.lua \
|
2021-01-22 12:25:31 +01:00
|
|
|
--subst-var-by NIX_LIBC_INCLUDE ${lib.getDev stdenv.cc.libc}/include
|
2016-01-18 01:50:10 +01:00
|
|
|
'';
|
|
|
|
|
2016-06-15 01:37:37 +02:00
|
|
|
preBuild = ''
|
2016-06-23 01:21:15 +02:00
|
|
|
cat >Makefile.inc<<EOF
|
2021-01-22 12:25:31 +01:00
|
|
|
CLANG = ${lib.getBin llvmPackages.clang-unwrapped}/bin/clang
|
|
|
|
LLVM_CONFIG = ${lib.getBin llvmPackages.llvm}/bin/llvm-config
|
2016-06-23 01:21:15 +02:00
|
|
|
EOF
|
|
|
|
|
2016-01-18 01:50:10 +01:00
|
|
|
mkdir -p build
|
|
|
|
cp ${luajitSrc} build/${luajitArchive}
|
|
|
|
'';
|
|
|
|
|
2019-09-19 07:26:48 +02:00
|
|
|
checkPhase = "(cd tests && ../terra run)";
|
|
|
|
|
2016-01-18 01:50:10 +01:00
|
|
|
installPhase = ''
|
2019-04-27 15:47:19 +02:00
|
|
|
install -Dm755 -t $bin/bin release/bin/terra
|
|
|
|
install -Dm755 -t $out/lib release/lib/terra${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
install -Dm644 -t $static/lib release/lib/libterra.a
|
2016-06-15 01:37:37 +02:00
|
|
|
|
|
|
|
mkdir -pv $dev/include
|
|
|
|
cp -rv release/include/terra $dev/include
|
2019-04-27 15:47:19 +02:00
|
|
|
'';
|
2016-01-18 01:50:10 +01:00
|
|
|
|
2021-01-22 12:25:31 +01:00
|
|
|
meta = with lib; {
|
2016-01-18 01:50:10 +01:00
|
|
|
description = "A low-level counterpart to Lua";
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "http://terralang.org/";
|
2019-09-19 04:44:55 +02:00
|
|
|
platforms = platforms.x86_64;
|
|
|
|
maintainers = with maintainers; [ jb55 thoughtpolice ];
|
|
|
|
license = licenses.mit;
|
2016-01-18 01:50:10 +01:00
|
|
|
};
|
|
|
|
}
|