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