From ac02f26980ffc6a84844943cb2c303662225543a Mon Sep 17 00:00:00 2001 From: Vincent Laporte Date: Tue, 22 Dec 2020 17:52:15 +0100 Subject: [PATCH] =?UTF-8?q?ocamlPackages.cppo:=201.6.{5,6}=20=E2=86=92=201?= =?UTF-8?q?.6.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ocamlPackages.cppo_ocamlbuild: init at 1.6.7 --- pkgs/development/tools/ocaml/cppo/default.nix | 99 ++++++++++--------- .../tools/ocaml/cppo/ocamlbuild.nix | 17 ++++ pkgs/top-level/ocaml-packages.nix | 2 + 3 files changed, 73 insertions(+), 45 deletions(-) create mode 100644 pkgs/development/tools/ocaml/cppo/ocamlbuild.nix diff --git a/pkgs/development/tools/ocaml/cppo/default.nix b/pkgs/development/tools/ocaml/cppo/default.nix index 63c169f045f9..a0215fa81471 100644 --- a/pkgs/development/tools/ocaml/cppo/default.nix +++ b/pkgs/development/tools/ocaml/cppo/default.nix @@ -1,56 +1,65 @@ -{ stdenv, fetchFromGitHub, ocaml, findlib, ocamlbuild, dune }: +{ stdenv, fetchurl, fetchFromGitHub, ocaml, findlib, ocamlbuild +, buildDunePackage +}: + let pname = "cppo"; - webpage = "https://github.com/ocaml-community/${pname}"; -in -assert stdenv.lib.versionAtLeast ocaml.version "3.12"; - -let param = - if stdenv.lib.versionAtLeast ocaml.version "4.02" then - (if stdenv.lib.versionAtLeast ocaml.version "4.03" then { - version = "1.6.6"; - sha256 = "1smcc0l6fh2n0y6bp96c69j5nw755jja99w0b206wx3yb2m4w2hs"; - } else { - version = "1.6.5"; - sha256 = "03c0amszy28shinvz61hm340jz446zz5763a1pdqlza36kwcj0p0"; - }) // { - buildInputs = [ dune ]; - extra = { - inherit (dune) installPhase; - }; - } else { - version = "1.5.0"; - sha256 = "1xqldjz9risndnabvadw41fdbi5sa2hl4fnqls7j9xfbby1izbg8"; - extra = { - createFindlibDestdir = true; - makeFlags = [ "PREFIX=$(out)" ]; - preBuild = '' - mkdir $out/bin - ''; - }; - } -; in - -stdenv.mkDerivation ({ - - name = "${pname}-${param.version}"; - - src = fetchFromGitHub { - owner = "mjambon"; - repo = pname; - rev = "v${param.version}"; - inherit (param) sha256; - }; - - buildInputs = [ ocaml findlib ocamlbuild ] ++ (param.buildInputs or []); meta = with stdenv.lib; { description = "The C preprocessor for OCaml"; longDescription = '' Cppo is an equivalent of the C preprocessor targeted at the OCaml language and its variants. ''; - homepage = webpage; + homepage = "https://github.com/ocaml-community/${pname}"; maintainers = [ maintainers.vbgl ]; license = licenses.bsd3; }; -} // param.extra) + +in + +if stdenv.lib.versionAtLeast ocaml.version "4.02" then + +buildDunePackage rec { + inherit pname; + version = "1.6.7"; + + useDune2 = true; + + src = fetchurl { + url = "https://github.com/ocaml-community/cppo/releases/download/v${version}/cppo-v${version}.tbz"; + sha256 = "17ajdzrnmnyfig3s6hinb56mcmhywbssxhsq32dz0v90dhz3wmfv"; + }; + + doCheck = true; + + inherit meta; +} + +else + +let version = "1.5.0"; in + +stdenv.mkDerivation { + + name = "${pname}-${version}"; + + src = fetchFromGitHub { + owner = "mjambon"; + repo = pname; + rev = "v${version}"; + sha256 = "1xqldjz9risndnabvadw41fdbi5sa2hl4fnqls7j9xfbby1izbg8"; + }; + + buildInputs = [ ocaml findlib ocamlbuild ]; + + inherit meta; + + createFindlibDestdir = true; + + makeFlags = [ "PREFIX=$(out)" ]; + + preBuild = '' + mkdir $out/bin + ''; + +} diff --git a/pkgs/development/tools/ocaml/cppo/ocamlbuild.nix b/pkgs/development/tools/ocaml/cppo/ocamlbuild.nix new file mode 100644 index 000000000000..633dc6bc7bf6 --- /dev/null +++ b/pkgs/development/tools/ocaml/cppo/ocamlbuild.nix @@ -0,0 +1,17 @@ +{ lib, buildDunePackage, cppo, ocamlbuild }: + +if !lib.versionAtLeast (lib.getVersion cppo) "1.6" +then cppo +else + +buildDunePackage rec { + pname = "cppo_ocamlbuild"; + + inherit (cppo) version useDune2 src; + + propagatedBuildInputs = [ ocamlbuild ]; + + meta = cppo.meta // { + description = "Plugin to use cppo with ocamlbuild"; + }; +} diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 5cc4cfb9a163..f16b55cf0938 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -161,6 +161,8 @@ let cppo = callPackage ../development/tools/ocaml/cppo { }; + cppo_ocamlbuild = callPackage ../development/tools/ocaml/cppo/ocamlbuild.nix { }; + cpu = callPackage ../development/ocaml-modules/cpu { }; cpuid = callPackage ../development/ocaml-modules/cpuid { };