summary refs log tree commit diff
path: root/pkgs/development/ocaml-modules/tls/default.nix
blob: 9343ae5b1ecf96274920515db157e44870bb93af (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, topkg
, ppx_sexp_conv, result, x509, nocrypto, cstruct-sexp, ppx_cstruct, cstruct-unix, ounit
, lwt     ? null}:

with stdenv.lib;

let withLwt = lwt != null; in

if !versionAtLeast ocaml.version "4.04"
then throw "tls is not available for OCaml ${ocaml.version}"
else

stdenv.mkDerivation rec {
  version = "0.10.4";
  name = "ocaml${ocaml.version}-tls-${version}";

  src = fetchFromGitHub {
    owner  = "mirleft";
    repo   = "ocaml-tls";
    rev    = version;
    sha256 = "02wv4lia583imn3sfci4nqv6ac5nzig5j3yfdnlqa0q8bp9rfc6g";
  };

  nativeBuildInputs = [ ocaml ocamlbuild findlib ];
  buildInputs = [ findlib topkg ppx_sexp_conv ppx_cstruct ]
  ++ optionals doCheck [ ounit cstruct-unix ];
  propagatedBuildInputs = [ cstruct-sexp nocrypto result x509 ] ++
                          optional withLwt lwt;

  buildPhase = "${topkg.run} build --tests ${boolToString doCheck} --with-mirage false --with-lwt ${boolToString withLwt}";

  doCheck = versionAtLeast ocaml.version "4.06";
  checkPhase = "${topkg.run} test";

  inherit (topkg) installPhase;

  meta = with stdenv.lib; {
    homepage = "https://github.com/mirleft/ocaml-tls";
    description = "TLS in pure OCaml";
    license = licenses.bsd2;
    maintainers = with maintainers; [ sternenseemann ];
  };
}