about summary refs log tree commit diff
path: root/pkgs/development/compilers/ante/default.nix
blob: f5b5d6cacaf7956a2d7e0d5456267a1a78f4a8b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ fetchFromGitHub
, lib
, libffi
, libxml2
, llvmPackages_13
, ncurses
, rustPlatform
}:

rustPlatform.buildRustPackage {
  pname = "ante";
  version = "unstable-2022-08-22";
  src = fetchFromGitHub {
    owner = "jfecher";
    repo = "ante";
    rev = "8b708d549c213c34e4ca62d31cf0dd25bfa7b548";
    sha256 = "sha256-s8nDuG32lI4pBLsOzgfyUGpc7/r0j4EhzH54ErBK7A0=";
  };
  cargoLock = {
    lockFile = ./Cargo.lock;
    outputHashes = {
      "inkwell-0.1.0" = "sha256-vWrpF66r5HalGQz2jSmQljfz0EgS7shLw7A8q75j3tE=";
    };
  };

  /*
     https://crates.io/crates/llvm-sys#llvm-compatibility
     llvm-sys requires a specific version of llvmPackages,
     that is not the same as the one included by default with rustPlatform.
  */
  nativeBuildInputs = [ llvmPackages_13.llvm ];
  buildInputs = [ libffi libxml2 ncurses ];

  postPatch = ''
    substituteInPlace tests/golden_tests.rs --replace \
      'target/debug' "target/$(rustc -vV | sed -n 's|host: ||p')/release"
  '';
  preBuild =
    let
      major = lib.versions.major llvmPackages_13.llvm.version;
      minor = lib.versions.minor llvmPackages_13.llvm.version;
      llvm-sys-ver = "${major}${builtins.substring 0 1 minor}";
    in
    ''
      # On some architectures llvm-sys is not using the package listed inside nativeBuildInputs
      export LLVM_SYS_${llvm-sys-ver}_PREFIX=${llvmPackages_13.llvm.dev}
      export ANTE_STDLIB_DIR=$out/lib
      mkdir -p $ANTE_STDLIB_DIR
      cp -r $src/stdlib/* $ANTE_STDLIB_DIR
    '';

  meta = with lib; {
    homepage = "https://antelang.org/";
    description = "A low-level functional language for exploring refinement types, lifetime inference, and algebraic effects";
    license = with licenses; [ mit ];
    maintainers = with maintainers; [ ehllie ];
  };
}