@@ -1,41 +1,28 @@
1−{ stdenv, fetchurl, ocaml, findlib, dune, alcotest, cmdliner, fmt, optint, rresult }:
1+{ lib, fetchurl, buildDunePackage
2+, bigarray-compat, optint
3+, cmdliner, fmt, rresult
4+, alcotest
5+}:
26
3−if !stdenv.lib.versionAtLeast ocaml.version "4.03"
4−then throw "checkseum is not available for OCaml ${ocaml.version}"
5−else
7+buildDunePackage rec {
8+ version = "0.1.1";
9+ pname = "checkseum";
610
7−# The C implementation is not portable: x86 only
8−let hasC = stdenv.isi686 || stdenv.isx86_64; in
9−
10−stdenv.mkDerivation rec {
11− version = "0.0.3";
12− name = "ocaml${ocaml.version}-checkseum-${version}";
1311 src = fetchurl {
14− url = "https://github.com/mirage/checkseum/releases/download/v0.0.3/checkseum-v0.0.3.tbz";
15− sha256 = "12j45zsvil1ynwx1x8fbddhqacc8r1zf7f6h576y3f3yvbg7l1fm";
12+ url = "https://github.com/mirage/checkseum/releases/download/v${version}/checkseum-v${version}.tbz";
13+ sha256 = "0aa2r1l65a5hcgciw6n8r5ij4gpgg0cf9k24isybxiaiz63k94d3";
1614 };
1715
18− postPatch = stdenv.lib.optionalString (!hasC) ''
19− rm -r bin src-c
20− '';
21−
22− buildInputs = [ ocaml findlib dune alcotest cmdliner fmt rresult ];
23− propagatedBuildInputs = [ optint ];
24−
25− buildPhase = "dune build";
26−
27− doCheck = hasC;
28− checkPhase = "dune runtest";
29−
30− inherit (dune) installPhase;
16+ buildInputs = [ cmdliner fmt rresult ];
17+ propagatedBuildInputs = [ bigarray-compat optint ];
18+ checkInputs = lib.optionals doCheck [ alcotest ];
3119
32− passthru = { inherit hasC; };
20+ doCheck = true;
3321
3422 meta = {
3523 homepage = "https://github.com/mirage/checkseum";
3624 description = "ADLER-32 and CRC32C Cyclic Redundancy Check";
37− license = stdenv.lib.licenses.mit;
38− maintainers = [ stdenv.lib.maintainers.vbgl ];
39− inherit (ocaml.meta) platforms;
25+ license = lib.licenses.mit;
26+ maintainers = [ lib.maintainers.vbgl ];
4027 };
4128}