at master 2.3 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 ncurses, 6 libX11, 7 xorgproto, 8 buildEnv, 9 useX11 ? stdenv.hostPlatform.isx86, 10}: 11 12let 13 x11deps = [ 14 libX11 15 xorgproto 16 ]; 17 inherit (lib) optionals; 18 19 baseOcamlBranch = "4.14"; 20 baseOcamlVersion = "${baseOcamlBranch}.1"; 21 metaocamlPatch = "114"; 22in 23 24stdenv.mkDerivation rec { 25 pname = "ber-metaocaml"; 26 version = metaocamlPatch; 27 28 src = fetchurl { 29 url = "https://caml.inria.fr/pub/distrib/ocaml-${baseOcamlBranch}/ocaml-${baseOcamlVersion}.tar.gz"; 30 sha256 = "sha256-GDl53JwJyw9YCiMraFMaCbAlqmKLjY1ydEnxRv1vX+4="; 31 }; 32 33 metaocaml = fetchurl { 34 url = "http://okmij.org/ftp/ML/ber-metaocaml-${metaocamlPatch}.tar.gz"; 35 sha256 = "sha256-vvq3xI4jSAsrXcDk97TPbFDYgO9NcQeN/yBcUbcb/y0="; 36 }; 37 38 x11env = buildEnv { 39 name = "x11env"; 40 paths = x11deps; 41 }; 42 x11lib = "${x11env}/lib"; 43 x11inc = "${x11env}/include"; 44 45 prefixKey = "-prefix "; 46 configureFlags = optionals useX11 [ "--enable-flambda" ]; 47 48 dontStrip = true; 49 buildInputs = [ ncurses ] ++ optionals useX11 x11deps; 50 51 postConfigure = '' 52 tar -xvzf $metaocaml 53 cd ${pname}-${version} 54 make patch 55 cd .. 56 ''; 57 58 buildPhase = '' 59 make world 60 61 make bootstrap 62 make opt.opt 63 make -i install 64 make installopt 65 mkdir -p $out/include 66 ln -sv $out/lib/ocaml/caml $out/include/caml 67 cd ${pname}-${version} 68 make all 69 ''; 70 71 installPhase = '' 72 make install 73 make install.opt 74 ''; 75 76 checkPhase = '' 77 cd ${pname}-${version} 78 make test 79 make test-compile 80 make test-native 81 cd .. 82 ''; 83 84 passthru = { 85 nativeCompilers = true; 86 }; 87 88 meta = with lib; { 89 description = "Multi-Stage Programming extension for OCaml"; 90 homepage = "https://okmij.org/ftp/ML/MetaOCaml.html"; 91 license = with licenses; [ 92 # compiler 93 qpl # library 94 lgpl2 95 ]; 96 maintainers = with maintainers; [ thoughtpolice ]; 97 98 branch = baseOcamlBranch; 99 platforms = with platforms; linux ++ darwin; 100 broken = stdenv.hostPlatform.isAarch64 || stdenv.hostPlatform.isMips; 101 102 longDescription = '' 103 A simple extension of OCaml with the primitive type of code values, and 104 three basic multi-stage expression forms: Brackets, Escape, and Run. 105 ''; 106 }; 107}