git.iko.soy/typeable/nixpkgs
on master help sign in
Convert OCaml from DocBook to CommonMark
commitf5baf84be56294f3839ff2d098d102e2b347a8d9 authorAndersonTorres <torres.anderson.85@protonmail.com> dateWed 2 Dec 2020, 01:09 (6 years ago) parentbb0399b
3 files changed+71−74
doc/languages-frameworks/index.xml+1−1 doc/languages-frameworks/ocaml.section.md+70 doc/languages-frameworks/ocaml.xml−73
doc/languages-frameworks/index.xml+1−1
@@ -21,7 +21,7 @@
2121 <xi:include href="lua.section.xml" />
2222 <xi:include href="maven.section.xml" />
2323 <xi:include href="node.section.xml" />
24− <xi:include href="ocaml.xml" />
24+ <xi:include href="ocaml.section.xml" />
2525 <xi:include href="perl.xml" />
2626 <xi:include href="php.section.xml" />
2727 <xi:include href="python.section.xml" />
doc/languages-frameworks/ocaml.section.mdnew file+70
@@ -0,0 +1,70 @@
1+# OCaml {#sec-language-ocaml}
2+
3+OCaml libraries should be installed in `$(out)/lib/ocaml/${ocaml.version}/site-lib/`. Such directories are automatically added to the `$OCAMLPATH` environment variable when building another package that depends on them or when opening a `nix-shell`.
4+
5+Given that most of the OCaml ecosystem is now built with dune, nixpkgs includes a convenience build support function called `buildDunePackage` that will build an OCaml package using dune, OCaml and findlib and any additional dependencies provided as `buildInputs` or `propagatedBuildInputs`.
6+
7+Here is a simple package example. It defines an (optional) attribute `minimumOCamlVersion` that will be used to throw a descriptive evaluation error if building with an older OCaml is attempted. It uses the `fetchFromGitHub` fetcher to get its source. It sets the `doCheck` (optional) attribute to `true` which means that tests will be run with `dune runtest -p angstrom` after the build (`dune build -p angstrom`) is complete. It uses `alcotest` as a build input (because it is needed to run the tests) and `bigstringaf` and `result` as propagated build inputs (thus they will also be available to libraries depending on this library). The library will be installed using the `angstrom.install` file that dune generates.
8+
9+```nix
10+{ stdenv
11+, fetchFromGitHub
12+, buildDunePackage
13+, alcotest
14+, result
15+, bigstringaf
16+}:
17+
18+buildDunePackage rec {
19+ pname = "angstrom";
20+ version = "0.10.0";
21+
22+ minimumOCamlVersion = "4.03";
23+
24+ src = fetchFromGitHub {
25+ owner = "inhabitedtype";
26+ repo = pname;
27+ rev = version;
28+ sha256 = "0lh6024yf9ds0nh9i93r9m6p5psi8nvrqxl5x7jwl13zb0r9xfpw";
29+ };
30+
31+ buildInputs = [ alcotest ];
32+ propagatedBuildInputs = [ bigstringaf result ];
33+ doCheck = true;
34+
35+ meta = {
36+ homepage = "https://github.com/inhabitedtype/angstrom";
37+ description = "OCaml parser combinators built for speed and memory efficiency";
38+ license = stdenv.lib.licenses.bsd3;
39+ maintainers = with stdenv.lib.maintainers; [ sternenseemann ];
40+ };
41+}
42+```
43+
44+Here is a second example, this time using a source archive generated with `dune-release`. It is a good idea to use this archive when it is available as it will usually contain substituted variables such as a `%%VERSION%%` field. This library does not depend on any other OCaml library and no tests are run after building it.
45+
46+```nix
47+{ stdenv
48+, fetchurl
49+, buildDunePackage
50+}:
51+
52+buildDunePackage rec {
53+ pname = "wtf8";
54+ version = "1.0.1";
55+
56+ minimumOCamlVersion = "4.01";
57+
58+ src = fetchurl {
59+ url = "https://github.com/flowtype/ocaml-${pname}/releases/download/v${version}/${pname}-${version}.tbz";
60+ sha256 = "1msg3vycd3k8qqj61sc23qks541cxpb97vrnrvrhjnqxsqnh6ygq";
61+ };
62+
63+ meta = with stdenv.lib; {
64+ homepage = "https://github.com/flowtype/ocaml-wtf8";
65+ description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates.";
66+ license = licenses.mit;
67+ maintainers = [ maintainers.eqyiel ];
68+ };
69+}
70+```
doc/languages-frameworks/ocaml.xmldeleted−73
@@ -1,73 +0,0 @@
1−<section xmlns="http://docbook.org/ns/docbook"
2− xmlns:xlink="http://www.w3.org/1999/xlink"
3− xml:id="sec-language-ocaml">
4− <title>OCaml</title>
5−
6− <para>
7− OCaml libraries should be installed in <literal>$(out)/lib/ocaml/${ocaml.version}/site-lib/</literal>. Such directories are automatically added to the <literal>$OCAMLPATH</literal> environment variable when building another package that depends on them or when opening a <literal>nix-shell</literal>.
8− </para>
9−
10− <para>
11− Given that most of the OCaml ecosystem is now built with dune, nixpkgs includes a convenience build support function called <literal>buildDunePackage</literal> that will build an OCaml package using dune, OCaml and findlib and any additional dependencies provided as <literal>buildInputs</literal> or <literal>propagatedBuildInputs</literal>.
12− </para>
13−
14− <para>
15− Here is a simple package example. It defines an (optional) attribute <literal>minimumOCamlVersion</literal> that will be used to throw a descriptive evaluation error if building with an older OCaml is attempted. It uses the <literal>fetchFromGitHub</literal> fetcher to get its source. It sets the <literal>doCheck</literal> (optional) attribute to <literal>true</literal> which means that tests will be run with <literal>dune runtest -p angstrom</literal> after the build (<literal>dune build -p angstrom</literal>) is complete. It uses <literal>alcotest</literal> as a build input (because it is needed to run the tests) and <literal>bigstringaf</literal> and <literal>result</literal> as propagated build inputs (thus they will also be available to libraries depending on this library). The library will be installed using the <literal>angstrom.install</literal> file that dune generates.
16− </para>
17−
18−<programlisting>
19−{ stdenv, fetchFromGitHub, buildDunePackage, alcotest, result, bigstringaf }:
20−
21−buildDunePackage rec {
22− pname = "angstrom";
23− version = "0.10.0";
24−
25− minimumOCamlVersion = "4.03";
26−
27− src = fetchFromGitHub {
28− owner = "inhabitedtype";
29− repo = pname;
30− rev = version;
31− sha256 = "0lh6024yf9ds0nh9i93r9m6p5psi8nvrqxl5x7jwl13zb0r9xfpw";
32− };
33−
34− buildInputs = [ alcotest ];
35− propagatedBuildInputs = [ bigstringaf result ];
36− doCheck = true;
37−
38− meta = {
39− homepage = "https://github.com/inhabitedtype/angstrom";
40− description = "OCaml parser combinators built for speed and memory efficiency";
41− license = stdenv.lib.licenses.bsd3;
42− maintainers = with stdenv.lib.maintainers; [ sternenseemann ];
43− };
44−}
45−</programlisting>
46−
47− <para>
48− Here is a second example, this time using a source archive generated with <literal>dune-release</literal>. It is a good idea to use this archive when it is available as it will usually contain substituted variables such as a <literal>%%VERSION%%</literal> field. This library does not depend on any other OCaml library and no tests are run after building it.
49− </para>
50−
51−<programlisting>
52−{ stdenv, fetchurl, buildDunePackage }:
53−
54−buildDunePackage rec {
55− pname = "wtf8";
56− version = "1.0.1";
57−
58− minimumOCamlVersion = "4.01";
59−
60− src = fetchurl {
61− url = "https://github.com/flowtype/ocaml-${pname}/releases/download/v${version}/${pname}-${version}.tbz";
62− sha256 = "1msg3vycd3k8qqj61sc23qks541cxpb97vrnrvrhjnqxsqnh6ygq";
63− };
64−
65− meta = with stdenv.lib; {
66− homepage = "https://github.com/flowtype/ocaml-wtf8";
67− description = "WTF-8 is a superset of UTF-8 that allows unpaired surrogates.";
68− license = licenses.mit;
69− maintainers = [ maintainers.eqyiel ];
70− };
71−}
72−</programlisting>
73−</section>