nixpkgs/pkgs/development/tools/ocaml/utop/default.nix

78 lines
2.3 KiB
Nix
Raw Normal View History

2018-06-24 06:18:35 +00:00
{ stdenv, fetchurl, bash, ocaml, findlib, ocamlbuild, jbuilder
, lambdaTerm, cppo, makeWrapper
2014-07-20 16:23:42 +00:00
}:
if !stdenv.lib.versionAtLeast ocaml.version "4.02"
then throw "utop is not available for OCaml ${ocaml.version}"
else
2014-07-20 16:23:42 +00:00
stdenv.mkDerivation rec {
2018-06-24 06:18:35 +00:00
version = "2.1.0";
2014-07-20 16:23:42 +00:00
name = "utop-${version}";
src = fetchurl {
url = "https://github.com/diml/utop/archive/${version}.tar.gz";
2018-06-24 06:18:35 +00:00
sha256 = "0lpfyhnm4v3xmcpac76g1px3x7na4p29w6xj2q8chqxhcw131n2y";
2014-07-20 16:23:42 +00:00
};
nativeBuildInputs = [ makeWrapper ];
2018-06-24 06:18:35 +00:00
buildInputs = [ ocaml findlib ocamlbuild cppo jbuilder ];
2014-07-20 16:23:42 +00:00
2018-06-24 06:18:35 +00:00
propagatedBuildInputs = [ lambdaTerm ];
2014-07-20 16:23:42 +00:00
2018-06-24 06:18:35 +00:00
inherit (jbuilder) installPhase;
2014-07-20 16:23:42 +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 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 06:51:30 +00:00
do
2017-05-01 12:38:18 +00: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 12:38:18 +00:00
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") \
--add-flags "-I ${findlib}/lib/ocaml/${stdenv.lib.getVersion ocaml}/site-lib"
2015-01-27 06:51:30 +00:00
done
'';
2014-07-20 16:23:42 +00: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;
platforms = ocaml.meta.platforms or [];
2014-07-20 16:23:42 +00:00
maintainers = [
stdenv.lib.maintainers.gal_bolle
];
};
}