git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #25122 from pmahoney/ocaml-utop

ocamlPackages.utop: fix environment variables

commit6955d023092285457e479a56d6af6a9c46b26fc4 authorMichael Raskin <7c6f434c@mail.ru> dateMon 1 May 2017, 14:38 (10 years ago) parent69250aa9ae5487
3 files changed+43−19
pkgs/development/ocaml-modules/lambda-term/default.nix+5−3 pkgs/development/ocaml-modules/lwt/default.nix+5−3 pkgs/development/tools/ocaml/utop/default.nix+33−13
pkgs/development/ocaml-modules/lambda-term/default.nix+5−3
@@ -1,10 +1,10 @@
1−{ stdenv, fetchurl, libev, ocaml, findlib, ocamlbuild, ocaml_lwt, ocaml_react, zed }:
1+{ stdenv, buildOcaml, fetchurl, libev, ocaml, findlib, ocamlbuild, ocaml_lwt, ocaml_react, zed }:
22
33assert stdenv.lib.versionAtLeast (stdenv.lib.getVersion ocaml) "4.01";
44
5−stdenv.mkDerivation rec {
5+buildOcaml rec {
66 version = "1.10";
7− name = "lambda-term-${version}";
7+ name = "lambda-term";
88
99 src = fetchurl {
1010 url = "https://github.com/diml/lambda-term/archive/${version}.tar.gz";
@@ -17,6 +17,8 @@ stdenv.mkDerivation rec {
1717
1818 createFindlibDestdir = true;
1919
20+ hasSharedObjects = true;
21+
2022 meta = { description = "Terminal manipulation library for OCaml";
2123 longDescription = ''
2224 Lambda-term is a cross-platform library for
pkgs/development/ocaml-modules/lwt/default.nix+5−3
@@ -1,4 +1,4 @@
1−{ stdenv, fetchzip, which, cryptopp, ocaml, findlib, ocamlbuild, camlp4
1+{ stdenv, buildOcaml, fetchzip, which, cryptopp, ocaml, findlib, ocamlbuild, camlp4
22, ocaml_react, ocaml_ssl, libev, pkgconfig, ncurses, ocaml_oasis, glib
33, ppx_tools, result, cppo
44, ppxSupport ? stdenv.lib.versionAtLeast ocaml.version "4.02"
@@ -15,8 +15,8 @@ let param =
1515 };
1616in
1717
18−stdenv.mkDerivation rec {
19− name = "ocaml-lwt-${version}";
18+buildOcaml rec {
19+ name = "lwt";
2020 inherit (param) version;
2121
2222 src = fetchzip {
@@ -36,6 +36,8 @@ stdenv.mkDerivation rec {
3636
3737 createFindlibDestdir = true;
3838
39+ hasSharedObjects = true;
40+
3941 meta = with stdenv.lib; {
4042 homepage = http://ocsigen.org/lwt;
4143 description = "Lightweight thread library for Objective Caml";
pkgs/development/tools/ocaml/utop/default.nix+33−13
@@ -28,21 +28,41 @@ stdenv.mkDerivation rec {
2828 dontStrip = true;
2929
3030 postFixup =
31− let p = p: "${p}/lib/ocaml/${ocaml.version}/site-lib"; in
32− ''
33− pushd $out/bin
34− for prog in *
31+ let
32+ path = "etc/utop/env";
33+
34+ # derivation of just runtime deps so env vars created by
35+ # setup-hooks can be saved for use at runtime
36+ runtime = stdenv.mkDerivation rec {
37+ name = "utop-runtime-env-${version}";
38+
39+ buildInputs = [ findlib ] ++ propagatedBuildInputs;
40+
41+ phases = [ "installPhase" ];
42+
43+ installPhase = ''
44+ mkdir -p "$out"/${path}
45+ for e in OCAMLPATH CAML_LD_LIBRARY_PATH; do
46+ printf %s "''${!e}" > "$out"/${path}/$e
47+ done
48+ '';
49+ };
50+
51+ get = key: ''$(cat "${runtime}/${path}/${key}")'';
52+ in ''
53+ for prog in "$out"/bin/*
3554 do
36− mv $prog .$prog-wrapped
37− cat > $prog <<EOF
38−#!${bash}/bin/bash -e
39−export CAML_LD_LIBRARY_PATH="${p ocaml_lwt}/lwt:${p lambdaTerm}/lambda-term:\$CAML_LD_LIBRARY_PATH"
40−export OCAMLPATH="${p ocaml_lwt}:${p ocaml_react}:${p camomile}:${p zed}:${p lambdaTerm}:"$out"/lib/ocaml/${ocaml.version}/site-lib:\$OCAMLPATH"
41−${ocaml}/bin/ocamlrun $out/bin/.$prog-wrapped \$*
42−EOF
43− chmod +x $prog
55+
56+ # Note: wrapProgram by default calls 'exec -a $0 ...', but this
57+ # breaks utop on Linux with OCaml 4.04, and is disabled with
58+ # '--argv0 ""' flag. See https://github.com/NixOS/nixpkgs/issues/24496
59+ wrapProgram "$prog" \
60+ --argv0 "" \
61+ --prefix CAML_LD_LIBRARY_PATH ":" "${get "CAML_LD_LIBRARY_PATH"}" \
62+ --prefix OCAMLPATH ":" "${get "OCAMLPATH"}" \
63+ --prefix OCAMLPATH ":" $(unset OCAMLPATH; addOCamlPath "$out"; printf %s "$OCAMLPATH")
64+
4465 done
45− popd
4666 '';
4767
4868 meta = {