Merge pull request #25122 from pmahoney/ocaml-utop

ocamlPackages.utop: fix environment variables
This commit is contained in:
Michael Raskin 2017-05-01 14:38:32 +02:00 committed by GitHub
commit 6955d02309
3 changed files with 43 additions and 19 deletions

View File

@ -1,10 +1,10 @@
{ stdenv, fetchurl, libev, ocaml, findlib, ocamlbuild, ocaml_lwt, ocaml_react, zed }: { stdenv, buildOcaml, fetchurl, libev, ocaml, findlib, ocamlbuild, ocaml_lwt, ocaml_react, zed }:
assert stdenv.lib.versionAtLeast (stdenv.lib.getVersion ocaml) "4.01"; assert stdenv.lib.versionAtLeast (stdenv.lib.getVersion ocaml) "4.01";
stdenv.mkDerivation rec { buildOcaml rec {
version = "1.10"; version = "1.10";
name = "lambda-term-${version}"; name = "lambda-term";
src = fetchurl { src = fetchurl {
url = "https://github.com/diml/lambda-term/archive/${version}.tar.gz"; url = "https://github.com/diml/lambda-term/archive/${version}.tar.gz";
@ -17,6 +17,8 @@ stdenv.mkDerivation rec {
createFindlibDestdir = true; createFindlibDestdir = true;
hasSharedObjects = true;
meta = { description = "Terminal manipulation library for OCaml"; meta = { description = "Terminal manipulation library for OCaml";
longDescription = '' longDescription = ''
Lambda-term is a cross-platform library for Lambda-term is a cross-platform library for

View File

@ -1,4 +1,4 @@
{ stdenv, fetchzip, which, cryptopp, ocaml, findlib, ocamlbuild, camlp4 { stdenv, buildOcaml, fetchzip, which, cryptopp, ocaml, findlib, ocamlbuild, camlp4
, ocaml_react, ocaml_ssl, libev, pkgconfig, ncurses, ocaml_oasis, glib , ocaml_react, ocaml_ssl, libev, pkgconfig, ncurses, ocaml_oasis, glib
, ppx_tools, result, cppo , ppx_tools, result, cppo
, ppxSupport ? stdenv.lib.versionAtLeast ocaml.version "4.02" , ppxSupport ? stdenv.lib.versionAtLeast ocaml.version "4.02"
@ -15,8 +15,8 @@ let param =
}; };
in in
stdenv.mkDerivation rec { buildOcaml rec {
name = "ocaml-lwt-${version}"; name = "lwt";
inherit (param) version; inherit (param) version;
src = fetchzip { src = fetchzip {
@ -36,6 +36,8 @@ stdenv.mkDerivation rec {
createFindlibDestdir = true; createFindlibDestdir = true;
hasSharedObjects = true;
meta = with stdenv.lib; { meta = with stdenv.lib; {
homepage = http://ocsigen.org/lwt; homepage = http://ocsigen.org/lwt;
description = "Lightweight thread library for Objective Caml"; description = "Lightweight thread library for Objective Caml";

View File

@ -28,21 +28,41 @@ stdenv.mkDerivation rec {
dontStrip = true; dontStrip = true;
postFixup = postFixup =
let p = p: "${p}/lib/ocaml/${ocaml.version}/site-lib"; in let
'' path = "etc/utop/env";
pushd $out/bin
for prog in * # 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/*
do do
mv $prog .$prog-wrapped
cat > $prog <<EOF # Note: wrapProgram by default calls 'exec -a $0 ...', but this
#!${bash}/bin/bash -e # breaks utop on Linux with OCaml 4.04, and is disabled with
export CAML_LD_LIBRARY_PATH="${p ocaml_lwt}/lwt:${p lambdaTerm}/lambda-term:\$CAML_LD_LIBRARY_PATH" # '--argv0 ""' flag. See https://github.com/NixOS/nixpkgs/issues/24496
export OCAMLPATH="${p ocaml_lwt}:${p ocaml_react}:${p camomile}:${p zed}:${p lambdaTerm}:"$out"/lib/ocaml/${ocaml.version}/site-lib:\$OCAMLPATH" wrapProgram "$prog" \
${ocaml}/bin/ocamlrun $out/bin/.$prog-wrapped \$* --argv0 "" \
EOF --prefix CAML_LD_LIBRARY_PATH ":" "${get "CAML_LD_LIBRARY_PATH"}" \
chmod +x $prog --prefix OCAMLPATH ":" "${get "OCAMLPATH"}" \
--prefix OCAMLPATH ":" $(unset OCAMLPATH; addOCamlPath "$out"; printf %s "$OCAMLPATH")
done done
popd
''; '';
meta = { meta = {