Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 buildDunePackage,
3 cmdliner,
4 cppo,
5 dune-build-info,
6 fetchurl,
7 jq,
8 lib,
9 makeWrapper,
10 menhirLib,
11 merlin,
12 nodejs,
13 ocaml,
14 ounit2,
15 ppxlib,
16 reason,
17 stdenv,
18 tree,
19}:
20
21let
22 pname = "melange";
23 versionHash =
24 if lib.versionAtLeast ocaml.version "5.3" then
25 {
26 version = "5.1.0-53";
27 hash = "sha256-96rDDzul/v+Dc+IWTNtbOKWUV8rf7HS1ZMK2LQNcpKk=";
28 }
29 else if lib.versionAtLeast ocaml.version "5.2" then
30 {
31 version = "5.1.0-52";
32 hash = "sha256-EGIInGCo3JADYyE4mLw5Fzkm4OB+V9yi2ayV0lVq3v0=";
33 }
34 else if lib.versionAtLeast ocaml.version "5.1" then
35 {
36 version = "5.1.0-51";
37 hash = "sha256-DIF8vZLEKsFf6m5tl1/T6zqjHyKxDMois2h//tDhsJI=";
38 }
39 else if lib.versionAtLeast ocaml.version "5.0" then
40 throw "melange is not available for OCaml ${ocaml.version}"
41 else
42 {
43 version = "5.1.0-414";
44 hash = "sha256-Sv1XyOqCNhICTsXzetXh/zqX/tdTupYZ0Q1nZRLfpe0=";
45 };
46 version = versionHash.version;
47 hash = versionHash.hash;
48in
49buildDunePackage {
50 inherit pname;
51 inherit version;
52 minimalOCamlVersion = "4.14";
53 src = fetchurl {
54 url = "https://github.com/melange-re/${pname}/releases/download/${version}/${pname}-${version}.tbz";
55 inherit hash;
56 };
57 nativeBuildInputs = [
58 cppo
59 makeWrapper
60 ];
61 buildInputs = [
62 cmdliner
63 dune-build-info
64 ];
65 propagatedBuildInputs = [
66 menhirLib
67 ppxlib
68 ];
69 doCheck = false;
70 nativeCheckInputs = [
71 jq
72 merlin
73 nodejs
74 reason
75 tree
76 ];
77 checkInputs = [
78 ounit2
79 ];
80 postInstall = ''
81 wrapProgram "$out/bin/melc" --set MELANGELIB "$OCAMLFIND_DESTDIR/melange/melange:$OCAMLFIND_DESTDIR/melange/js/melange"
82 '';
83 meta = {
84 description = "Toolchain to produce JS from Reason/OCaml";
85 homepage = "https://melange.re/";
86 mainProgram = "melc";
87 license = lib.licenses.lgpl3;
88 maintainers = [
89 lib.maintainers.vog
90 ];
91 };
92}