nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 buildDunePackage,
6 ocaml,
7 findlib,
8 alcotest,
9 astring,
10 cmdliner,
11 cppo,
12 fmt,
13 logs,
14 ocaml-version,
15 camlp-streams,
16 lwt,
17 re,
18 result,
19 csexp,
20 gitUpdater,
21}:
22
23buildDunePackage (finalAttrs: {
24 pname = "mdx";
25 version = "2.5.1";
26
27 src = fetchurl {
28 url = "https://github.com/realworldocaml/mdx/releases/download/${finalAttrs.version}/mdx-${finalAttrs.version}.tbz";
29 hash = "sha256-3YKYDdERpIBv+akdnS7Xwmrvsdp9zL0V5zw6j2boY/U=";
30 };
31
32 env =
33 # Fix build with gcc15
34 lib.optionalAttrs
35 (
36 lib.versionAtLeast ocaml.version "4.10" && lib.versionOlder ocaml.version "4.14"
37 || lib.versions.majorMinor ocaml.version == "5.0"
38 )
39 {
40 NIX_CFLAGS_COMPILE = "-std=gnu11";
41 };
42
43 nativeBuildInputs = [ cppo ];
44 propagatedBuildInputs = [
45 astring
46 fmt
47 logs
48 csexp
49 cmdliner
50 ocaml-version
51 camlp-streams
52 re
53 result
54 findlib
55 ];
56 checkInputs = [
57 alcotest
58 lwt
59 ];
60
61 doCheck = !stdenv.hostPlatform.isDarwin;
62
63 outputs = [
64 "bin"
65 "lib"
66 "out"
67 ];
68
69 installPhase = ''
70 runHook preInstall
71 dune install --prefix=$bin --libdir=$lib/lib/ocaml/${ocaml.version}/site-lib mdx
72 runHook postInstall
73 '';
74
75 passthru.updateScript = gitUpdater { };
76
77 meta = {
78 description = "Executable OCaml code blocks inside markdown files";
79 homepage = "https://github.com/realworldocaml/mdx";
80 changelog = "https://github.com/realworldocaml/mdx/raw/${finalAttrs.version}/CHANGES.md";
81 license = lib.licenses.isc;
82 maintainers = [ lib.maintainers.romildo ];
83 mainProgram = "ocaml-mdx";
84 };
85})