2021-06-06 00:48:45 +01:00
|
|
|
{ lib, stdenv, fetchurl, fetchFromGitHub, llvmPackages, ncurses, cmake, libxml2
|
|
|
|
, symlinkJoin, breakpointHook }:
|
2016-06-15 00:37:37 +01:00
|
|
|
|
|
|
|
let
|
2021-05-16 07:02:00 +01:00
|
|
|
luajitRev = "9143e86498436892cb4316550be4d45b68a61224";
|
|
|
|
luajitArchive = "LuaJIT-${luajitRev}.tar.gz";
|
2016-06-15 00:37:37 +01:00
|
|
|
luajitSrc = fetchurl {
|
2021-05-16 07:02:00 +01:00
|
|
|
url = "https://github.com/LuaJIT/LuaJIT/archive/${luajitRev}.tar.gz";
|
|
|
|
sha256 = "0kasmyk40ic4b9dwd4wixm0qk10l88ardrfimwmq36yc5dhnizmy";
|
2016-06-15 00:37:37 +01:00
|
|
|
};
|
2021-06-06 00:48:45 +01:00
|
|
|
llvmMerged = symlinkJoin {
|
|
|
|
name = "llvmClangMerged";
|
|
|
|
paths = with llvmPackages; [
|
|
|
|
llvm.out
|
|
|
|
llvm.dev
|
|
|
|
llvm.lib
|
|
|
|
clang-unwrapped.out
|
|
|
|
clang-unwrapped.dev
|
|
|
|
clang-unwrapped.lib
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in stdenv.mkDerivation rec {
|
2019-09-19 04:13:18 +01:00
|
|
|
pname = "terra";
|
2021-05-16 07:02:00 +01:00
|
|
|
version = "1.0.0-beta3";
|
2016-01-18 00:50:10 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2021-06-06 00:48:45 +01:00
|
|
|
owner = "terralang";
|
|
|
|
repo = "terra";
|
|
|
|
rev = "release-${version}";
|
2021-05-16 07:02:00 +01:00
|
|
|
sha256 = "15ik32xnwyf3g57jvvaz24f6a18lv3a86341rzjbs30kd5045qzd";
|
2016-01-18 00:50:10 +00:00
|
|
|
};
|
|
|
|
|
2021-05-16 07:02:00 +01:00
|
|
|
nativeBuildInputs = [ cmake ];
|
2021-06-06 00:48:45 +01:00
|
|
|
buildInputs = [ llvmMerged ncurses libxml2 ];
|
2021-05-16 07:02:00 +01:00
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DHAS_TERRA_VERSION=0"
|
|
|
|
"-DTERRA_VERSION=${src.rev}"
|
|
|
|
"-DTERRA_LUA=luajit"
|
|
|
|
];
|
2019-09-19 04:13:18 +01:00
|
|
|
|
2019-09-19 06:26:48 +01:00
|
|
|
doCheck = true;
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
hardeningDisable = [ "fortify" ];
|
2016-08-29 01:30:01 +01:00
|
|
|
outputs = [ "bin" "dev" "out" "static" ];
|
2016-06-15 00:37:37 +01:00
|
|
|
|
2021-05-16 07:02:00 +01:00
|
|
|
patches = [
|
|
|
|
# Should be removed as https://github.com/terralang/terra/pull/496 get merged and released.
|
|
|
|
./get-compiler-from-envvar-fix-cpu-detection.patch
|
|
|
|
./nix-cflags.patch
|
|
|
|
./disable-luajit-file-download.patch
|
2021-06-06 00:48:45 +01:00
|
|
|
./nix-add-test-paths.patch
|
2021-05-16 07:02:00 +01:00
|
|
|
];
|
2021-06-06 00:48:45 +01:00
|
|
|
|
|
|
|
INCLUDE_PATH = "${llvmMerged}/lib/clang/10.0.1/include";
|
|
|
|
|
2016-06-15 00:37:37 +01:00
|
|
|
postPatch = ''
|
2019-09-19 06:26:48 +01:00
|
|
|
substituteInPlace src/terralib.lua \
|
2021-01-22 11:25:31 +00:00
|
|
|
--subst-var-by NIX_LIBC_INCLUDE ${lib.getDev stdenv.cc.libc}/include
|
2021-06-06 00:48:45 +01:00
|
|
|
|
|
|
|
substituteInPlace src/CMakeLists.txt \
|
|
|
|
--subst-var INCLUDE_PATH
|
2016-01-18 00:50:10 +00:00
|
|
|
'';
|
|
|
|
|
2021-05-16 07:02:00 +01:00
|
|
|
preConfigure = ''
|
2016-01-18 00:50:10 +00:00
|
|
|
mkdir -p build
|
|
|
|
cp ${luajitSrc} build/${luajitArchive}
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-05-16 07:02:00 +01:00
|
|
|
install -Dm755 -t $bin/bin bin/terra
|
|
|
|
install -Dm755 -t $out/lib lib/terra${stdenv.hostPlatform.extensions.sharedLibrary}
|
|
|
|
install -Dm644 -t $static/lib lib/libterra_s.a
|
2016-06-15 00:37:37 +01:00
|
|
|
|
|
|
|
mkdir -pv $dev/include
|
2021-05-16 07:02:00 +01:00
|
|
|
cp -rv include/terra $dev/include
|
2019-04-27 14:47:19 +01:00
|
|
|
'';
|
2016-01-18 00:50:10 +00:00
|
|
|
|
2021-01-22 11:25:31 +00:00
|
|
|
meta = with lib; {
|
2016-01-18 00:50:10 +00:00
|
|
|
description = "A low-level counterpart to Lua";
|
2021-06-06 00:48:45 +01:00
|
|
|
homepage = "http://terralang.org/";
|
|
|
|
platforms = platforms.x86_64;
|
2019-09-19 03:44:55 +01:00
|
|
|
maintainers = with maintainers; [ jb55 thoughtpolice ];
|
2021-06-06 00:48:45 +01:00
|
|
|
license = licenses.mit;
|
2016-01-18 00:50:10 +00:00
|
|
|
};
|
|
|
|
}
|