2017-10-05 07:57:03 +02:00
|
|
|
{ stdenv, fetchurl, bash, ocaml, findlib, ocamlbuild, camlp4
|
2017-05-03 15:48:21 +02:00
|
|
|
, lambdaTerm, ocaml_lwt, camomile, zed, cppo, ppx_tools, makeWrapper
|
2014-07-20 18:23:42 +02:00
|
|
|
}:
|
|
|
|
|
2017-07-02 14:22:53 +02:00
|
|
|
if !stdenv.lib.versionAtLeast ocaml.version "4.02"
|
|
|
|
then throw "utop is not available for OCaml ${ocaml.version}"
|
|
|
|
else
|
|
|
|
|
2014-07-20 18:23:42 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2017-02-24 20:21:29 +01:00
|
|
|
version = "1.19.3";
|
2014-07-20 18:23:42 +02:00
|
|
|
name = "utop-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2015-07-28 17:31:44 +02:00
|
|
|
url = "https://github.com/diml/utop/archive/${version}.tar.gz";
|
2017-02-24 20:21:29 +01:00
|
|
|
sha256 = "16z02vp9n97iax4fqpbi7v86r75vbabxvnd1rirh8w2miixs1g4x";
|
2014-07-20 18:23:42 +02:00
|
|
|
};
|
|
|
|
|
2017-05-03 15:48:21 +02:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2017-04-08 13:34:41 +02:00
|
|
|
buildInputs = [ ocaml findlib ocamlbuild cppo camlp4 ppx_tools ];
|
2014-07-20 18:23:42 +02:00
|
|
|
|
|
|
|
propagatedBuildInputs = [ lambdaTerm ocaml_lwt ];
|
|
|
|
|
|
|
|
createFindlibDestdir = true;
|
|
|
|
|
2016-06-05 21:18:23 +02:00
|
|
|
configureFlags = [ "--enable-camlp4" ]
|
2017-02-24 20:21:29 +01:00
|
|
|
++ stdenv.lib.optional (ppx_tools != null && !stdenv.lib.versionAtLeast ocaml.version "4.04") "--enable-interact";
|
2015-07-28 17:31:44 +02:00
|
|
|
|
2014-07-20 18:23:42 +02:00
|
|
|
buildPhase = ''
|
|
|
|
make
|
|
|
|
make doc
|
|
|
|
'';
|
|
|
|
|
2017-04-01 07:39:13 +02:00
|
|
|
dontStrip = true;
|
|
|
|
|
2014-07-20 18:23:42 +02:00
|
|
|
postFixup =
|
2017-04-22 21:01:05 +02:00
|
|
|
let
|
|
|
|
path = "etc/utop/env";
|
|
|
|
|
|
|
|
# derivation of just runtime deps so env vars created by
|
|
|
|
# setup-hooks can be saved for use at runtime
|
|
|
|
runtime = stdenv.mkDerivation rec {
|
|
|
|
name = "utop-runtime-env-${version}";
|
|
|
|
|
|
|
|
buildInputs = [ findlib ] ++ propagatedBuildInputs;
|
|
|
|
|
|
|
|
phases = [ "installPhase" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out"/${path}
|
|
|
|
for e in OCAMLPATH CAML_LD_LIBRARY_PATH; do
|
|
|
|
printf %s "''${!e}" > "$out"/${path}/$e
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
get = key: ''$(cat "${runtime}/${path}/${key}")'';
|
|
|
|
in ''
|
|
|
|
for prog in "$out"/bin/*
|
2015-01-27 07:51:30 +01:00
|
|
|
do
|
2017-05-01 14:38:18 +02:00
|
|
|
|
2017-04-22 21:01:05 +02:00
|
|
|
# Note: wrapProgram by default calls 'exec -a $0 ...', but this
|
|
|
|
# breaks utop on Linux with OCaml 4.04, and is disabled with
|
|
|
|
# '--argv0 ""' flag. See https://github.com/NixOS/nixpkgs/issues/24496
|
2017-05-01 14:38:18 +02:00
|
|
|
wrapProgram "$prog" \
|
2017-04-22 21:01:05 +02:00
|
|
|
--argv0 "" \
|
|
|
|
--prefix CAML_LD_LIBRARY_PATH ":" "${get "CAML_LD_LIBRARY_PATH"}" \
|
|
|
|
--prefix OCAMLPATH ":" "${get "OCAMLPATH"}" \
|
2017-06-15 16:15:24 +02:00
|
|
|
--prefix OCAMLPATH ":" $(unset OCAMLPATH; addOCamlPath "$out"; printf %s "$OCAMLPATH") \
|
|
|
|
--add-flags "-I ${findlib}/lib/ocaml/${stdenv.lib.getVersion ocaml}/site-lib"
|
2015-01-27 07:51:30 +01:00
|
|
|
done
|
|
|
|
'';
|
2014-07-20 18:23:42 +02:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Universal toplevel for OCaml";
|
|
|
|
longDescription = ''
|
|
|
|
utop is an improved toplevel for OCaml. It can run in a terminal or in Emacs. It supports line edition, history, real-time and context sensitive completion, colors, and more.
|
|
|
|
|
|
|
|
It integrates with the tuareg mode in Emacs.
|
|
|
|
'';
|
|
|
|
homepage = https://github.com/diml/utop;
|
|
|
|
license = stdenv.lib.licenses.bsd3;
|
2015-12-24 18:49:07 +01:00
|
|
|
platforms = ocaml.meta.platforms or [];
|
2014-07-20 18:23:42 +02:00
|
|
|
maintainers = [
|
|
|
|
stdenv.lib.maintainers.gal_bolle
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|