2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchurl, ocaml, findlib
|
2022-03-05 16:20:37 +00:00
|
|
|
, lambda-term, cppo, makeWrapper, buildDunePackage
|
2023-07-15 17:15:38 +00:00
|
|
|
, xdg, zed, logs, lwt, react, lwt_react
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildDunePackage rec {
|
|
|
|
pname = "utop";
|
2022-10-21 18:38:19 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "2.13.0";
|
|
|
|
propagatedBuildInputs = [ findlib lambda-term xdg zed logs ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
minimalOCamlVersion = "4.11";
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/ocaml-community/utop/releases/download/${version}/utop-${version}.tbz";
|
2023-07-15 17:15:38 +00:00
|
|
|
sha256 = "sha256-iEUPIABsLRB4Gr6YQbrSpX5ymLXs8b4zu/Hq3r0Shtg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-05 16:20:37 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper cppo ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postFixup =
|
|
|
|
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 {
|
|
|
|
pname = "utop-runtime-env";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
buildInputs = [ findlib ] ++ propagatedBuildInputs;
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
dontUnpack = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p "$out"/${path}
|
|
|
|
for e in OCAMLPATH CAML_LD_LIBRARY_PATH; do
|
|
|
|
[[ -v "$e" ]] || continue
|
|
|
|
printf %s "''${!e}" > "$out"/${path}/$e
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
get = key: ''$(cat "${runtime}/${path}/${key}")'';
|
|
|
|
in ''
|
|
|
|
for prog in "$out"/bin/*
|
|
|
|
do
|
|
|
|
|
|
|
|
# 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
|
|
|
|
wrapProgram "$prog" \
|
|
|
|
--argv0 "" \
|
|
|
|
--prefix CAML_LD_LIBRARY_PATH ":" "${get "CAML_LD_LIBRARY_PATH"}" \
|
|
|
|
--prefix OCAMLPATH ":" "${get "OCAMLPATH"}" \
|
|
|
|
--prefix OCAMLPATH ":" $(unset OCAMLPATH; addOCamlPath "$out"; printf %s "$OCAMLPATH") \
|
2021-02-05 17:12:51 +00:00
|
|
|
--add-flags "-I ${findlib}/lib/ocaml/${lib.getVersion ocaml}/site-lib"
|
2020-04-24 23:36:52 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
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.
|
|
|
|
'';
|
2023-07-15 17:15:38 +00:00
|
|
|
homepage = "https://github.com/ocaml-community/utop";
|
|
|
|
changelog = "https://github.com/ocaml-community/utop/blob/${version}/CHANGES.md";
|
2021-02-05 17:12:51 +00:00
|
|
|
license = lib.licenses.bsd3;
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = ocaml.meta.platforms or [];
|
|
|
|
maintainers = [
|
2021-02-05 17:12:51 +00:00
|
|
|
lib.maintainers.gal_bolle
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|