1{ fetchFromGitHub
2, lib
3, libffi
4, libxml2
5, llvmPackages_13
6, ncurses
7, rustPlatform
8}:
9
10rustPlatform.buildRustPackage {
11 pname = "ante";
12 version = "unstable-2022-08-22";
13 src = fetchFromGitHub {
14 owner = "jfecher";
15 repo = "ante";
16 rev = "8b708d549c213c34e4ca62d31cf0dd25bfa7b548";
17 sha256 = "sha256-s8nDuG32lI4pBLsOzgfyUGpc7/r0j4EhzH54ErBK7A0=";
18 };
19 cargoLock = {
20 lockFile = ./Cargo.lock;
21 outputHashes = {
22 "inkwell-0.1.0" = "sha256-vWrpF66r5HalGQz2jSmQljfz0EgS7shLw7A8q75j3tE=";
23 };
24 };
25
26 /*
27 https://crates.io/crates/llvm-sys#llvm-compatibility
28 llvm-sys requires a specific version of llvmPackages,
29 that is not the same as the one included by default with rustPlatform.
30 */
31 nativeBuildInputs = [ llvmPackages_13.llvm ];
32 buildInputs = [ libffi libxml2 ncurses ];
33
34 postPatch = ''
35 substituteInPlace tests/golden_tests.rs --replace \
36 'target/debug' "target/$(rustc -vV | sed -n 's|host: ||p')/release"
37 '';
38 preBuild =
39 let
40 major = lib.versions.major llvmPackages_13.llvm.version;
41 minor = lib.versions.minor llvmPackages_13.llvm.version;
42 llvm-sys-ver = "${major}${builtins.substring 0 1 minor}";
43 in
44 ''
45 # On some architectures llvm-sys is not using the package listed inside nativeBuildInputs
46 export LLVM_SYS_${llvm-sys-ver}_PREFIX=${llvmPackages_13.llvm.dev}
47 export ANTE_STDLIB_DIR=$out/lib
48 mkdir -p $ANTE_STDLIB_DIR
49 cp -r $src/stdlib/* $ANTE_STDLIB_DIR
50 '';
51
52 meta = with lib; {
53 homepage = "https://antelang.org/";
54 description = "A low-level functional language for exploring refinement types, lifetime inference, and algebraic effects";
55 license = with licenses; [ mit ];
56 maintainers = with maintainers; [ ehllie ];
57 };
58}