Merge pull request #119126 from fabaff/pycomfoconnect
[NixPkgs.git] / pkgs / development / ocaml-modules / nocrypto / default.nix
blob055e6db3a645297cd08678f117475ab1c819d69a
1 { stdenv, lib, fetchurl, fetchpatch, ocaml, findlib, ocamlbuild, topkg
2 , cpuid, ocb-stubblr, sexplib
3 , cstruct, zarith, ppx_sexp_conv, ppx_deriving, writeScriptBin
4 , cstruct-lwt ? null
5 }:
7 with lib;
8 let
9   withLwt = cstruct-lwt != null;
10   # the build system will call 'cc' with no way to override
11   # this is wrong when we're cross-compiling, so insert a wrapper
12   cc-wrapper = writeScriptBin "cc" ''
13     set -e
14     $CC "$@"
15   '';
18 if !versionAtLeast ocaml.version "4.08"
19 then throw "nocrypto is not available for OCaml ${ocaml.version}"
20 else
22 stdenv.mkDerivation rec {
23   name = "ocaml${ocaml.version}-nocrypto-${version}";
24   version = "0.5.4";
26   src = fetchurl {
27     url = "https://github.com/mirleft/ocaml-nocrypto/releases/download/v${version}/nocrypto-${version}.tbz";
28     sha256 = "0zshi9hlhcz61n5z1k6fx6rsi0pl4xgahsyl2jp0crqkaf3hqwlg";
29   };
31   patches = [
32     (fetchpatch {
33       url = "https://raw.githubusercontent.com/ocaml/opam-repository/master/packages/nocrypto/nocrypto.0.5.4-1/files/0001-add-missing-runtime-dependencies-in-_tags.patch";
34       sha256 = "1asybwj3rl07b4q4cxwy80a7j17j0i5vzz77p38hymilhc2ky7xn";
35     })
36     (fetchpatch {
37       url = "https://raw.githubusercontent.com/ocaml/opam-repository/master/packages/nocrypto/nocrypto.0.5.4-1/files/0002-add-ppx_sexp_conv-as-a-runtime-dependency-in-the-pac.patch";
38       sha256 = "0zmp64n5fgkawpkyw0vv0bg0i2c3xbsxqy17vwy92nf5rbardi1r";
39     })
40     (fetchpatch {
41       url = "https://raw.githubusercontent.com/ocaml/opam-repository/master/packages/nocrypto/nocrypto.0.5.4-1/files/0003-Auto-detect-ppx_sexp_conv-runtime-library.patch";
42       sha256 = "0lngbg5gyd5gs56lbjh6g86cps1y8x1xsqzi0vi1v28al1gn5dhw";
43     })
44     (fetchpatch {
45       url = "https://raw.githubusercontent.com/ocaml/opam-repository/master/packages/nocrypto/nocrypto.0.5.4-1/files/0004-pack-package-workaround-ocamlbuild-272.patch";
46       sha256 = "16k0w78plvqhl17qiqq1mckxhhcdysqgs94l54a1bn0l6fx3rvb9";
47     })
48     (fetchpatch {
49       url = "https://raw.githubusercontent.com/ocaml/opam-repository/master/packages/nocrypto/nocrypto.0.5.4-1/files/0005-use-modern-cstruct-findlib.patch";
50       sha256 = "021k38zbdidw6g7j4vjxlnbsrnzq07bnavxzdjq23nbwlifs2nq9";
51     })
52     (fetchpatch {
53       url = "https://raw.githubusercontent.com/ocaml/opam-repository/master/packages/nocrypto/nocrypto.0.5.4-1/files/0006-explicit-dependency-on-sexplib.patch";
54       sha256 = "15kd0qgi96yxr3qkmaqny591l0s6qmwpprxd5xdx9qwv72hq813z";
55     })
56   ];
58   nativeBuildInputs = [ ocaml findlib ocamlbuild cc-wrapper ];
59   buildInputs = [ ocamlbuild findlib topkg cpuid ocb-stubblr ];
60   propagatedBuildInputs = [ cstruct ppx_deriving ppx_sexp_conv sexplib zarith ] ++ optional withLwt cstruct-lwt;
62   buildPhase = "${topkg.buildPhase} --accelerate false --with-lwt ${boolToString withLwt}";
63   inherit (topkg) installPhase;
65   meta = {
66     homepage = "https://github.com/mirleft/ocaml-nocrypto";
67     description = "Simplest possible crypto to support TLS";
68     license = lib.licenses.bsd2;
69     maintainers = with lib.maintainers; [ vbgl ];
70   };