From 2d136204c47985c9518105e1af9e14810c8319ec Mon Sep 17 00:00:00 2001 From: Vincent Laporte Date: Sat, 12 Nov 2016 10:17:30 +0100 Subject: [PATCH] ocamlPackages.cstruct: 1.6.0 -> 1.9.0, 2.3.0 --- .../ocaml-modules/cstruct/default.nix | 33 ++++++++++++------- .../ocaml-modules/nocrypto/default.nix | 4 +-- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/pkgs/development/ocaml-modules/cstruct/default.nix b/pkgs/development/ocaml-modules/cstruct/default.nix index c9f04918d17..dd6cffb979c 100644 --- a/pkgs/development/ocaml-modules/cstruct/default.nix +++ b/pkgs/development/ocaml-modules/cstruct/default.nix @@ -1,20 +1,31 @@ -{stdenv, writeText, fetchurl, ocaml, ocplib-endian, sexplib_p4, findlib, - async_p4 ? null, lwt ? null, camlp4}: +{ stdenv, writeText, fetchFromGitHub, ocaml, ocplib-endian, sexplib_p4, findlib, ppx_tools +, async_p4 ? null, lwt ? null, camlp4 +}: -assert stdenv.lib.versionAtLeast (stdenv.lib.getVersion ocaml) "4.01"; +assert stdenv.lib.versionAtLeast ocaml.version "4.01"; + +let param = + if stdenv.lib.versionAtLeast ocaml.version "4.02" + then { version = "2.3.0"; sha256 = "19spsgkry41dhsbm6ij71kws90bqp7wiggc6lsqdl43xxvbgdmys"; } + else { version = "1.9.0"; sha256 = "1c1j21zgmxi9spq23imy7byn50qr7hlds1cfpzxlsx9dp309jngy"; }; +in + +let opt = b: "--${if b != null then "en" else "dis"}able"; in stdenv.mkDerivation { - name = "ocaml-cstruct-1.6.0"; + name = "ocaml${ocaml.version}-cstruct-${param.version}"; - src = fetchurl { - url = https://github.com/mirage/ocaml-cstruct/archive/v1.6.0.tar.gz; - sha256 = "0f90a1b7a03091cf22a3ccb11a0cce03b6500f064ad3766b5ed81418ac008ece"; + src = fetchFromGitHub { + owner = "mirage"; + repo = "ocaml-cstruct"; + rev = "v${param.version}"; + inherit (param) sha256; }; - configureFlags = stdenv.lib.strings.concatStringsSep " " ((if lwt != null then ["--enable-lwt"] else []) ++ - (if async_p4 != null then ["--enable-async"] else [])); - buildInputs = [ocaml findlib camlp4]; - propagatedBuildInputs = [ocplib-endian sexplib_p4 lwt async_p4]; + configureFlags = [ "${opt lwt}-lwt" "${opt async_p4}-async" "${opt ppx_tools}-ppx" ]; + + buildInputs = [ ocaml findlib ppx_tools camlp4 lwt async_p4 ]; + propagatedBuildInputs = [ ocplib-endian sexplib_p4 ]; createFindlibDestdir = true; dontStrip = true; diff --git a/pkgs/development/ocaml-modules/nocrypto/default.nix b/pkgs/development/ocaml-modules/nocrypto/default.nix index f8db935b612..fab048a9a9f 100644 --- a/pkgs/development/ocaml-modules/nocrypto/default.nix +++ b/pkgs/development/ocaml-modules/nocrypto/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchzip, ocaml, findlib, cstruct, type_conv, zarith, ounit }: +{ stdenv, fetchzip, ocaml, findlib, cstruct, type_conv, zarith, ocaml_lwt, ounit }: assert stdenv.lib.versionAtLeast ocaml.version "4.01"; @@ -11,7 +11,7 @@ stdenv.mkDerivation rec { sha256 = "15gffvixk12ghsfra9amfszd473c8h188zfj03ngvblbdm0d80m0"; }; - buildInputs = [ ocaml findlib type_conv ounit ]; + buildInputs = [ ocaml findlib type_conv ocaml_lwt ounit ]; propagatedBuildInputs = [ cstruct zarith ]; configureFlags = "--enable-tests";