about summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/zarith
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2019-01-14 21:50:15 -0600
committerAustin Seipp <aseipp@pobox.com>2019-01-15 01:28:11 -0600
commit564653f91d7031495a0b955c744a578352f34576 (patch)
tree8cf067b33ca62fc0e1032ee313f8e944d1a92f3b /pkgs/development/ocaml-modules/zarith
parentb44d5136e8a8d2d40727699acf38eccf8a0b15e1 (diff)
downloadnixlib-564653f91d7031495a0b955c744a578352f34576.tar
nixlib-564653f91d7031495a0b955c744a578352f34576.tar.gz
nixlib-564653f91d7031495a0b955c744a578352f34576.tar.bz2
nixlib-564653f91d7031495a0b955c744a578352f34576.tar.lz
nixlib-564653f91d7031495a0b955c744a578352f34576.tar.xz
nixlib-564653f91d7031495a0b955c744a578352f34576.tar.zst
nixlib-564653f91d7031495a0b955c744a578352f34576.zip
ocamlPackages.zarith: use buildOcaml instead of mkDerivation
This has two main advantages:

  - By setting hasSharedObjects = true, buildOcaml will automatically
include a setup-hook.sh that sets CAML_LD_LIBRARY_PATH in dependent
expressions. This is needed to pick up dllzarith.so properly which is
shipped as part of the library.

  - We can kill the ugly assert in the expression and instead change it
to use minimumSupportedOcamlVersion.

(Note: this was reverted in b44d5136e8a8d2d407, but the change is
exactly equivalent -- I wasn't sure what impact zarith might actually
have without checking OfBorg, which I wanted to do first.)

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'pkgs/development/ocaml-modules/zarith')
-rw-r--r--pkgs/development/ocaml-modules/zarith/default.nix23
1 files changed, 13 insertions, 10 deletions
diff --git a/pkgs/development/ocaml-modules/zarith/default.nix b/pkgs/development/ocaml-modules/zarith/default.nix
index e5d954970589..d91f6e1c8a31 100644
--- a/pkgs/development/ocaml-modules/zarith/default.nix
+++ b/pkgs/development/ocaml-modules/zarith/default.nix
@@ -1,8 +1,9 @@
-{ stdenv, fetchurl, ocaml, findlib, pkgconfig, gmp, perl }:
+{ stdenv, buildOcaml, fetchurl
+, ocaml, findlib, pkgconfig, perl
+, gmp
+}:
 
-assert stdenv.lib.versionAtLeast ocaml.version "3.12.1";
-
-let param =
+let source =
   if stdenv.lib.versionAtLeast ocaml.version "4.02"
   then {
     version = "1.7";
@@ -15,18 +16,20 @@ let param =
   };
 in
 
-stdenv.mkDerivation rec {
-  name = "zarith-${version}";
-  inherit (param) version;
+buildOcaml rec {
+  name = "zarith";
+  inherit (source) version;
+  src = fetchurl { inherit (source) url sha256; };
 
-  src = fetchurl {
-    inherit (param) url sha256;
-  };
+  minimumSupportedOcamlVersion = "3.12.1";
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ ocaml findlib perl ];
   propagatedBuildInputs = [ gmp ];
 
+  # needed so setup-hook.sh sets CAML_LD_LIBRARY_PATH for dllzarith.so
+  hasSharedObjects = true;
+
   patchPhase = "patchShebangs ./z_pp.pl";
   configurePhase = ''
     ./configure -installdir $out/lib/ocaml/${ocaml.version}/site-lib