nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 ocaml,
6 findlib,
7 perl,
8 makeWrapper,
9 rresult,
10 bos,
11 pcre2,
12 re,
13 camlp-streams,
14 legacy ? false,
15}:
16
17stdenv.mkDerivation (
18 finalAttrs:
19 let
20 recent = lib.versionAtLeast (lib.versions.major finalAttrs.version) "8";
21 in
22 {
23
24 version = if lib.versionAtLeast ocaml.version "4.12" && !legacy then "8.04.00" else "7.14";
25
26 pname = "ocaml${ocaml.version}-camlp5";
27
28 src = fetchFromGitHub {
29 owner = "camlp5";
30 repo = "camlp5";
31 tag =
32 if recent then
33 finalAttrs.version
34 else
35 "rel${builtins.replaceStrings [ "." ] [ "" ] finalAttrs.version}";
36 hash =
37 {
38 "8.04.00" = "sha256-5IQVGm/tqEzXmZmSYGbGqX+KN9nQLQgw+sBP+F2keXo=";
39 "8.03.2" = "sha256-nz+VfGR/6FdBvMzPPpVpviAXXBWNqM3Ora96Yzx964o=";
40 "7.14" = "sha256-/ORtS0uc/GN+g3y6N5ftjL4OBSqV6iswLRbfpeNCprU=";
41 }
42 ."${finalAttrs.version}";
43 };
44 nativeBuildInputs = [
45 ocaml
46 perl
47 ]
48 ++ lib.optionals recent [
49 makeWrapper
50 findlib
51 ];
52
53 buildInputs = lib.optionals recent [
54 bos
55 pcre2
56 re
57 rresult
58 ];
59
60 propagatedBuildInputs = lib.optional recent camlp-streams;
61
62 strictDeps = true;
63
64 prefixKey = "-prefix ";
65
66 preConfigure = ''
67 configureFlagsArray=(--strict --libdir $out/lib/ocaml/${ocaml.version}/site-lib)
68 patchShebangs ./config/find_stuffversion.pl etc/META.pl tools/ ocaml_src/tools/
69 '';
70
71 buildFlags = [ "world.opt" ];
72
73 postInstall = lib.optionalString recent ''
74 for prog in camlp5 camlp5o camlp5r camlp5sch mkcamlp5 ocpp5
75 do
76 wrapProgram $out/bin/$prog \
77 --prefix CAML_LD_LIBRARY_PATH : "$CAML_LD_LIBRARY_PATH"
78 done
79 '';
80 dontStrip = true;
81
82 meta = {
83 broken =
84 lib.versionAtLeast ocaml.version "5.04" && !lib.versionAtLeast finalAttrs.version "8.04.00";
85 description = "Preprocessor-pretty-printer for OCaml";
86 longDescription = ''
87 Camlp5 is a preprocessor and pretty-printer for OCaml programs.
88 It also provides parsing and printing tools.
89 '';
90 homepage = "https://camlp5.github.io/";
91 license = lib.licenses.bsd3;
92 platforms = ocaml.meta.platforms or [ ];
93 maintainers = [ lib.maintainers.vbgl ];
94 };
95 }
96)