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