Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / applications / virtualization / sail-riscv / default.nix
blob9a1f650132fda063a82d6b3a2f0bc7bf65c2a994
1 { stdenv
2 , fetchFromGitHub
3 , fetchpatch
4 , lib
5 , arch
6 , ocamlPackages
7 , ocaml
8 , zlib
9 , z3
13 stdenv.mkDerivation rec {
14   pname = "sail-riscv";
15   version = "0.5";
17   src = fetchFromGitHub {
18     owner = "riscv";
19     repo = pname;
20     rev = version;
21     hash = "sha256-7PZNNUMaCZEBf0lOCqkquewRgZPooBOjIbGF7JlLnEo=";
22   };
24   nativeBuildInputs = with ocamlPackages; [ ocamlbuild findlib ocaml z3 sail ];
25   buildInputs = with ocamlPackages; [ zlib linksem ];
26   strictDeps = true;
28   patches = [
29     (fetchpatch {
30       url = "https://github.com/riscv/sail-riscv/pull/250/commits/8bd37c484b83a8ce89c8bb7a001b8ae34dc4d77f.patch";
31       hash = "sha256-tDgkGhcbT6phoCAvilxMI56YUuUqQFgvh+2QduOjdMg=";
32     })
33   ];
35   postPatch = ''
36     rm -r prover_snapshots
37   '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
38     substituteInPlace Makefile --replace "-flto" ""
39   '';
41   makeFlags = [
42     "SAIL=sail"
43     "ARCH=${arch}"
44     "SAIL_DIR=${ocamlPackages.sail}/share/sail"
45     "LEM_DIR=${ocamlPackages.sail}/share/lem"
46   ];
48   installPhase = ''
49     runHook preInstall
51     mkdir -p $out/bin
52     cp c_emulator/riscv_sim_${arch} $out/bin
53     mkdir $out/share/
54     cp -r generated_definitions/{coq,hol4,isabelle} $out/share/
56     runHook postInstall
57   '';
60   meta = with lib; {
61     homepage = "https://github.com/riscv/sail-riscv";
62     description = "A formal specification of the RISC-V architecture, written in Sail";
63     maintainers = with maintainers; [ genericnerdyusername ];
64     broken = stdenv.isDarwin && stdenv.isAarch64;
65     license = licenses.bsd2;
66   };