From 0a85cfd2de9da64ea596d4473b1544721fa5e8c3 Mon Sep 17 00:00:00 2001
From: Allan Blanchard <allan.blanchard@cea.fr>
Date: Mon, 11 Jul 2022 15:33:04 +0200
Subject: [PATCH] [ci] more recent camlp5

---
 nix/camlp5.nix | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 nix/pkgs.nix   |  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 nix/camlp5.nix

diff --git a/nix/camlp5.nix b/nix/camlp5.nix
new file mode 100644
index 00000000000..0cccdbe19cd
--- /dev/null
+++ b/nix/camlp5.nix
@@ -0,0 +1,56 @@
+
+{ lib
+, stdenv
+, fetchFromGitHub
+, findlib
+, camlp-streams
+, ocaml
+, ocaml-compiler-libs
+, perl
+}:
+
+if lib.versionOlder ocaml.version "4.02"
+|| lib.versionOlder "4.15" ocaml.version
+then throw "camlp5 is not available for OCaml ${ocaml.version}"
+else
+
+stdenv.mkDerivation rec {
+
+  pname = "camlp5";
+  version = "8.00.03";
+
+  src = fetchFromGitHub {
+    owner = "camlp5";
+    repo = "camlp5";
+    rev = "rel${version}";
+    sha256 = "1fnvmaw9cland09pjx5h6w3f6fz9s23l4nbl4m9fcaa2i4dpraz6";
+  };
+
+  buildInputs = [ findlib camlp-streams ocaml perl ];
+
+  prefixKey = "-prefix ";
+
+  preConfigure = ''
+    configureFlagsArray=(--strict --libdir $out/lib/ocaml/${ocaml.version}/site-lib)
+    patchShebangs ./config/find_stuffversion.pl
+    patchShebangs ./etc/META.pl
+  '';
+
+  buildFlags = [ "world.opt" ];
+
+  dontStrip = true;
+
+  meta = with lib; {
+    description = "Preprocessor-pretty-printer for OCaml";
+    longDescription = ''
+      Camlp5 is a preprocessor and pretty-printer for OCaml programs.
+      It also provides parsing and printing tools.
+    '';
+    homepage = "https://camlp5.github.io/";
+    license = licenses.bsd3;
+    platforms = ocaml.meta.platforms or [];
+    maintainers = with maintainers; [
+      maggesi vbgl
+    ];
+  };
+}
diff --git a/nix/pkgs.nix b/nix/pkgs.nix
index f2750a73d49..5d9239ba765 100644
--- a/nix/pkgs.nix
+++ b/nix/pkgs.nix
@@ -3,6 +3,7 @@ let
   ocamlOverlay = oself: osuper: {
     # External Packages
     alt-ergo = oself.callPackage ./alt-ergo.nix {};
+    camlp5 = oself.callPackage ./camlp5.nix {};
     camlzip = oself.callPackage ./camlzip.nix {};
     headache = oself.callPackage ./headache.nix {};
     mlmpfr = oself.callPackage ./mlmpfr.nix {};
-- 
GitLab