From 02682e509389a6de23a2614da3b43abebf45a4f2 Mon Sep 17 00:00:00 2001 From: Patrick Mahoney Date: Sat, 22 Apr 2017 13:33:09 -0500 Subject: [PATCH 1/3] ocamlPackages.ocaml_lwt: use buildOcaml This adds the shared objects setup hook to prepare CAML_LD_LIBRARY_PATH. --- pkgs/development/ocaml-modules/lwt/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/ocaml-modules/lwt/default.nix b/pkgs/development/ocaml-modules/lwt/default.nix index 53d5a25a39eb..d450a877517e 100644 --- a/pkgs/development/ocaml-modules/lwt/default.nix +++ b/pkgs/development/ocaml-modules/lwt/default.nix @@ -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"; From d27e250627dd2f03e1436410c69b49f6463874ca Mon Sep 17 00:00:00 2001 From: Patrick Mahoney Date: Sat, 22 Apr 2017 13:36:23 -0500 Subject: [PATCH 2/3] ocamlPackages.lambdaTerm: use buildOcaml This adds the shared objects setup hook to prepare CAML_LD_LIBRARY_PATH. --- pkgs/development/ocaml-modules/lambda-term/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/development/ocaml-modules/lambda-term/default.nix b/pkgs/development/ocaml-modules/lambda-term/default.nix index f66773d426af..86e4ebccbae6 100644 --- a/pkgs/development/ocaml-modules/lambda-term/default.nix +++ b/pkgs/development/ocaml-modules/lambda-term/default.nix @@ -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 From 1a7586ce24598c03c2ab823e74e5e2413b450cdf Mon Sep 17 00:00:00 2001 From: Patrick Mahoney Date: Sat, 22 Apr 2017 14:01:05 -0500 Subject: [PATCH 3/3] ocamlPackages.utop: fix environment variables In the wrapper scripts, both OCAMLPATH and CAML_LD_LIBRARY_PATH where being created with a trailing literal $OCAMLPATH, rather than the expanded version. Thus if, for example, ocamlPackages.core was present in OCAMLPATH prior to running utop, the wrapper script would set the variable to $utop_dependencies:'$OCAMLPATH', and when using utop to open Core.Std, the following error was reported: findlib: [WARNING] cannot read directory $OCAMLPATH: No such file or directory This patch fixes the quoting issue, and further refactors the build to use standard wrapProgram helper, and uses an "inner derivation" to re-use the setupHook machinery of buildOCaml and findlib instead of manually specifying the OCAMLPATH required for utop along with transitive dependencies. --- pkgs/development/tools/ocaml/utop/default.nix | 44 +++++++++++++------ 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/pkgs/development/tools/ocaml/utop/default.nix b/pkgs/development/tools/ocaml/utop/default.nix index 31549729cfe7..bec72939fa07 100644 --- a/pkgs/development/tools/ocaml/utop/default.nix +++ b/pkgs/development/tools/ocaml/utop/default.nix @@ -28,21 +28,39 @@ 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 <