1{ lib
2, fetchFromGitHub
3, buildDunePackage
4, base64
5, omd
6, menhir
7, ott
8, linenoise
9, dune-site
10, pprint
11, makeWrapper
12, lem
13, linksem
14, yojson
15}:
16
17buildDunePackage rec {
18 pname = "sail";
19 version = "0.16";
20
21 src = fetchFromGitHub {
22 owner = "rems-project";
23 repo = "sail";
24 rev = version;
25 hash = "sha256-HY/rgWi0S7ZiAWZF0fVIRK6fpoJ7Xp5EQcxoPRCPJ5Y=";
26 };
27
28 minimalOCamlVersion = "4.08";
29
30 nativeBuildInputs = [
31 makeWrapper
32 ott
33 menhir
34 lem
35 ];
36
37 propagatedBuildInputs = [
38 base64
39 omd
40 dune-site
41 linenoise
42 pprint
43 linksem
44 yojson
45 ];
46
47 preBuild = ''
48 rm -r aarch* # Remove code derived from non-bsd2 arm spec
49 rm -r snapshots # Some of this might be derived from stuff in the aarch dir, it builds fine without it
50 '';
51 # `buildDunePackage` only builds the [pname] package
52 # This doesnt work in this case, as sail includes multiple packages in the same source tree
53 buildPhase = ''
54 runHook preBuild
55 dune build --release ''${enableParallelBuild:+-j $NIX_BUILD_CORES}
56 runHook postBuild
57 '';
58 checkPhase = ''
59 runHook preCheck
60 dune runtest ''${enableParallelBuild:+-j $NIX_BUILD_CORES}
61 runHook postCheck
62 '';
63 installPhase = ''
64 runHook preInstall
65 dune install --prefix $out --libdir $OCAMLFIND_DESTDIR
66 runHook postInstall
67 '';
68 postInstall = ''
69 wrapProgram $out/bin/sail --set SAIL_DIR $out/share/sail
70 '';
71
72 meta = with lib; {
73 homepage = "https://github.com/rems-project/sail";
74 description = "Language for describing the instruction-set architecture (ISA) semantics of processors";
75 maintainers = with maintainers; [ genericnerdyusername ];
76 license = licenses.bsd2;
77 };
78}