1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 ocaml,
6 findlib,
7 ocamlbuild,
8}:
9
10if lib.versionOlder ocaml.version "4.08" then
11 throw "wasm is not available for OCaml ${ocaml.version}"
12else
13
14 stdenv.mkDerivation rec {
15 pname = "ocaml${ocaml.version}-wasm";
16 version = "2.0.1";
17
18 src = fetchFromGitHub {
19 owner = "WebAssembly";
20 repo = "spec";
21 rev = "opam-${version}";
22 hash = "sha256-5eo8MIui2GxRS5X9az0NlLGZfxi5KGsTI/EaP6m/zts=";
23 };
24
25 nativeBuildInputs = [
26 ocaml
27 findlib
28 ocamlbuild
29 ];
30 strictDeps = true;
31
32 # x86_64-unknown-linux-musl-ld: -r and -pie may not be used together
33 hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
34
35 makeFlags = [
36 "-C"
37 "interpreter"
38 ];
39
40 createFindlibDestdir = true;
41
42 postInstall = ''
43 mkdir $out/bin
44 cp -L interpreter/wasm $out/bin
45 '';
46
47 meta = {
48 description = "Executable and OCaml library to run, read and write Web Assembly (wasm) files and manipulate their AST";
49 mainProgram = "wasm";
50 license = lib.licenses.asl20;
51 maintainers = [ lib.maintainers.vbgl ];
52 homepage = "https://github.com/WebAssembly/spec/tree/master/interpreter";
53 inherit (ocaml.meta) platforms;
54 };
55 }