diff --git a/pkgs/development/ocaml-modules/logs/default.nix b/pkgs/development/ocaml-modules/logs/default.nix index 2befcaa51dcc9..bbe31bcb13a9c 100644 --- a/pkgs/development/ocaml-modules/logs/default.nix +++ b/pkgs/development/ocaml-modules/logs/default.nix @@ -3,20 +3,32 @@ stdenv, fetchurl, ocaml, - findlib, - ocamlbuild, + version ? if lib.versionAtLeast ocaml.version "4.14" then "0.9.0" else "0.8.0", topkg, - result, - lwt, + buildTopkgPackage, + cmdlinerSupport ? true, cmdliner, - fmt, fmtSupport ? lib.versionAtLeast ocaml.version "4.08", - js_of_ocaml-compiler, + fmt, jsooSupport ? true, + js_of_ocaml-compiler, lwtSupport ? true, - cmdlinerSupport ? true, + lwt, }: let + param = + { + "0.8.0" = { + minimalOCamlVersion = "4.03"; + sha512 = "c34c67b00d6a989a2660204ea70db8521736d6105f15d1ee0ec6287a662798fe5c4d47075c6e7c84f5d5372adb5af5c4c404f79db70d69140af5e0ebbea3b6a5"; + }; + "0.9.0" = { + minimalOCamlVersion = "4.14"; + sha512 = "b75fb28e83f33461b06b5c9b60972c4a9a9a1599d637b4a0c7b1e86a87f34fe5361e817cb31f42ad7e7cbb822473b28fab9f58a02870eb189ebe88dae8e045ff"; + }; + } + .${version}; + pname = "logs"; webpage = "https://erratique.ch/software/${pname}"; @@ -48,40 +60,26 @@ let ]) optional_deps; optional_buildInputs = map (d: d.pkg) (lib.filter (d: d.enabled) optional_deps); in +buildTopkgPackage { + inherit pname version; + inherit (param) minimalOCamlVersion; -if lib.versionOlder ocaml.version "4.03" then - throw "logs is not available for OCaml ${ocaml.version}" -else - - stdenv.mkDerivation rec { - name = "ocaml${ocaml.version}-${pname}-${version}"; - version = "0.8.0"; - - src = fetchurl { - url = "${webpage}/releases/${pname}-${version}.tbz"; - hash = "sha256-mmFRQJX6QvMBIzJiO2yNYF1Ce+qQS2oNF3+OwziCNtg="; - }; - - nativeBuildInputs = [ - ocaml - findlib - ocamlbuild - topkg - ]; - buildInputs = [ topkg ] ++ optional_buildInputs; - propagatedBuildInputs = [ result ]; + src = fetchurl { + url = "${webpage}/releases/${pname}-${version}.tbz"; + inherit (param) sha512; + }; - strictDeps = true; + buildInputs = [ topkg ] ++ optional_buildInputs; - buildPhase = "${topkg.run} build ${lib.escapeShellArgs enable_flags}"; + strictDeps = true; - inherit (topkg) installPhase; + buildPhase = "${topkg.run} build ${lib.escapeShellArgs enable_flags}"; - meta = with lib; { - description = "Logging infrastructure for OCaml"; - homepage = webpage; - inherit (ocaml.meta) platforms; - maintainers = [ maintainers.sternenseemann ]; - license = licenses.isc; - }; - } + meta = with lib; { + description = "Logging infrastructure for OCaml"; + homepage = webpage; + inherit (ocaml.meta) platforms; + maintainers = [ maintainers.sternenseemann ]; + license = licenses.isc; + }; +}