about summary refs log tree commit diff
path: root/pkgs/applications/virtualization/sail-riscv/default.nix
blob: cda1f5d6cb20f1a43ee6956a668ee8f8e0fb0fa1 (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
59
60
61
62
63
64
65
66
67
{ stdenv
, fetchFromGitHub
, fetchpatch
, lib
, arch
, ocamlPackages
, ocaml
, zlib
, z3
}:


stdenv.mkDerivation rec {
  pname = "sail-riscv";
  version = "0.5";

  src = fetchFromGitHub {
    owner = "riscv";
    repo = pname;
    rev = version;
    hash = "sha256-7PZNNUMaCZEBf0lOCqkquewRgZPooBOjIbGF7JlLnEo=";
  };

  nativeBuildInputs = with ocamlPackages; [ ocamlbuild findlib ocaml z3 sail ];
  buildInputs = with ocamlPackages; [ zlib linksem ];
  strictDeps = true;

  patches = [
    (fetchpatch {
      url = "https://github.com/riscv/sail-riscv/pull/250/commits/8bd37c484b83a8ce89c8bb7a001b8ae34dc4d77f.patch";
      hash = "sha256-tDgkGhcbT6phoCAvilxMI56YUuUqQFgvh+2QduOjdMg=";
    })
  ];

  postPatch = ''
    rm -r prover_snapshots
  '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
    substituteInPlace Makefile --replace "-flto" ""
  '';

  makeFlags = [
    "SAIL=sail"
    "ARCH=${arch}"
    "SAIL_DIR=${ocamlPackages.sail}/share/sail"
    "LEM_DIR=${ocamlPackages.sail}/share/lem"
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp c_emulator/riscv_sim_${arch} $out/bin
    mkdir $out/share/
    cp -r generated_definitions/{coq,hol4,isabelle} $out/share/

    runHook postInstall
  '';


  meta = with lib; {
    homepage = "https://github.com/riscv/sail-riscv";
    description = "Formal specification of the RISC-V architecture, written in Sail";
    maintainers = with maintainers; [ genericnerdyusername ];
    broken = stdenv.isDarwin && stdenv.isAarch64;
    license = licenses.bsd2;
  };
}