3
0
Fork 0
forked from mirrors/nixpkgs

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";
stdenv.mkDerivation rec {
buildOcaml rec {
version = "1.10";
name = "lambda-term-${version}";
name = "lambda-term";
src = fetchurl {
url = "https://github.com/diml/lambda-term/archive/${version}.tar.gz";
@ -17,6 +17,8 @@ stdenv.mkDerivation rec {
createFindlibDestdir = true;
hasSharedObjects = true;
meta = { description = "Terminal manipulation library for OCaml";
longDescription = ''
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
, ppx_tools, result, cppo
, ppxSupport ? stdenv.lib.versionAtLeast ocaml.version "4.02"
@ -15,8 +15,8 @@ let param =
};
in
stdenv.mkDerivation rec {
name = "ocaml-lwt-${version}";
buildOcaml rec {
name = "lwt";
inherit (param) version;
src = fetchzip {
@ -36,6 +36,8 @@ stdenv.mkDerivation rec {
createFindlibDestdir = true;
hasSharedObjects = true;
meta = with stdenv.lib; {
homepage = http://ocsigen.org/lwt;
description = "Lightweight thread library for Objective Caml";

View file

@ -28,21 +28,41 @@ stdenv.mkDerivation rec {
dontStrip = true;
postFixup =
let p = p: "${p}/lib/ocaml/${ocaml.version}/site-lib"; in
''
pushd $out/bin
for prog in *
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/*
do
mv $prog .$prog-wrapped
cat > $prog <<EOF
#!${bash}/bin/bash -e
export CAML_LD_LIBRARY_PATH="${p ocaml_lwt}/lwt:${p lambdaTerm}/lambda-term:\$CAML_LD_LIBRARY_PATH"
export OCAMLPATH="${p ocaml_lwt}:${p ocaml_react}:${p camomile}:${p zed}:${p lambdaTerm}:"$out"/lib/ocaml/${ocaml.version}/site-lib:\$OCAMLPATH"
${ocaml}/bin/ocamlrun $out/bin/.$prog-wrapped \$*
EOF
chmod +x $prog
# 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")
done
popd
'';
meta = {