2019-08-20 22:10:15 -07:00
|
|
|
{ stdenv, fetchurl, ocaml, findlib, dune
|
2019-12-18 01:23:00 -08:00
|
|
|
, lambdaTerm, cppo, makeWrapper, buildDunePackage
|
2014-07-20 09:23:42 -07:00
|
|
|
}:
|
|
|
|
|
2019-02-22 09:00:57 -08:00
|
|
|
if !stdenv.lib.versionAtLeast ocaml.version "4.03"
|
2017-07-02 05:22:53 -07:00
|
|
|
then throw "utop is not available for OCaml ${ocaml.version}"
|
|
|
|
else
|
|
|
|
|
2019-12-18 01:23:00 -08:00
|
|
|
buildDunePackage rec {
|
2019-08-15 05:41:18 -07:00
|
|
|
pname = "utop";
|
2020-01-21 07:33:24 -08:00
|
|
|
version = "2.4.3";
|
2014-07-20 09:23:42 -07:00
|
|
|
|
|
|
|
src = fetchurl {
|
2019-11-12 04:24:35 -08:00
|
|
|
url = "https://github.com/ocaml-community/utop/releases/download/${version}/utop-${version}.tbz";
|
2020-01-21 07:33:24 -08:00
|
|
|
sha256 = "107al0l3x4a5kkjka7glmhsqlm7pwzzc6shspiv5gsjb49pblc2f";
|
2014-07-20 09:23:42 -07:00
|
|
|
};
|
|
|
|
|
2017-05-03 06:48:21 -07:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2019-12-18 01:23:00 -08:00
|
|
|
buildInputs = [ cppo ];
|
2014-07-20 09:23:42 -07:00
|
|
|
|
2018-06-23 23:18:35 -07:00
|
|
|
propagatedBuildInputs = [ lambdaTerm ];
|
2014-07-20 09:23:42 -07:00
|
|
|
|
|
|
|
postFixup =
|
2017-04-22 12:01:05 -07: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
|
2019-08-13 14:52:01 -07:00
|
|
|
runtime = stdenv.mkDerivation {
|
2019-08-13 14:52:01 -07:00
|
|
|
pname = "utop-runtime-env";
|
|
|
|
inherit version;
|
2017-04-22 12:01:05 -07:00
|
|
|
|
|
|
|
buildInputs = [ findlib ] ++ propagatedBuildInputs;
|
|
|
|
|
|
|
|
phases = [ "installPhase" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out"/${path}
|
|
|
|
for e in OCAMLPATH CAML_LD_LIBRARY_PATH; do
|
2019-11-14 10:44:07 -08:00
|
|
|
[[ -v "$e" ]] || continue
|
2017-04-22 12:01:05 -07:00
|
|
|
printf %s "''${!e}" > "$out"/${path}/$e
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
get = key: ''$(cat "${runtime}/${path}/${key}")'';
|
|
|
|
in ''
|
|
|
|
for prog in "$out"/bin/*
|
2015-01-26 22:51:30 -08:00
|
|
|
do
|
2017-05-01 05:38:18 -07:00
|
|
|
|
2017-04-22 12:01:05 -07: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 05:38:18 -07:00
|
|
|
wrapProgram "$prog" \
|
2017-04-22 12:01:05 -07:00
|
|
|
--argv0 "" \
|
|
|
|
--prefix CAML_LD_LIBRARY_PATH ":" "${get "CAML_LD_LIBRARY_PATH"}" \
|
|
|
|
--prefix OCAMLPATH ":" "${get "OCAMLPATH"}" \
|
2017-06-15 07:15:24 -07:00
|
|
|
--prefix OCAMLPATH ":" $(unset OCAMLPATH; addOCamlPath "$out"; printf %s "$OCAMLPATH") \
|
|
|
|
--add-flags "-I ${findlib}/lib/ocaml/${stdenv.lib.getVersion ocaml}/site-lib"
|
2015-01-26 22:51:30 -08:00
|
|
|
done
|
|
|
|
'';
|
2014-07-20 09:23:42 -07: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.
|
|
|
|
'';
|
2020-03-31 18:11:51 -07:00
|
|
|
homepage = "https://github.com/diml/utop";
|
2014-07-20 09:23:42 -07:00
|
|
|
license = stdenv.lib.licenses.bsd3;
|
2015-12-24 09:49:07 -08:00
|
|
|
platforms = ocaml.meta.platforms or [];
|
2014-07-20 09:23:42 -07:00
|
|
|
maintainers = [
|
|
|
|
stdenv.lib.maintainers.gal_bolle
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|