···11# OCaml {#sec-language-ocaml}
2233+## User guide {#sec-language-ocaml-user-guide}
44+55+OCaml libraries are available in attribute sets of the form `ocaml-ng.ocamlPackages_X_XX` where X is to be replaced with the desired compiler version. For example, ocamlgraph compiled with OCaml 4.12 can be found in `ocaml-ng.ocamlPackages_4_12.ocamlgraph`. The compiler itself is also located in this set, under the name `ocaml`.
66+77+If you don't care about the exact compiler version, `ocamlPackages` is a top-level alias pointing to a recent version of OCaml.
88+99+OCaml applications are usually available top-level, and not inside `ocamlPackages`. Notable exceptions are build tools that must be built with the same compiler version as the compiler you intend to use like `dune` or `ocaml-lsp`.
1010+1111+To open a shell able to build a typical OCaml project, put the dependencies in `buildInputs` and add `ocamlPackages.ocaml` and `ocamlPackages.findlib` to `nativeBuildInputs` at least.
1212+For example:
1313+```nix
1414+let
1515+ pkgs = import <nixpkgs> {};
1616+ # choose the ocaml version you want to use
1717+ ocamlPackages = pkgs.ocaml-ng.ocamlPackages_4_12;
1818+in
1919+pkgs.mkShell {
2020+ # build tools
2121+ nativeBuildInputs = with ocamlPackages; [ ocaml findlib dune_2 ocaml-lsp ];
2222+ # dependencies
2323+ buildInputs = with ocamlPackages; [ ocamlgraph ];
2424+}
2525+```
2626+2727+## Packaging guide {#sec-language-ocaml-packaging}
2828+329OCaml 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`.
430531Given 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`.
···11+{ lib, stdenv, fetchFromGitHub
22+, drat-trim, p7zip
33+}:
44+55+stdenv.mkDerivation rec {
66+ pname = "kissat";
77+ version = "2.0.1";
88+99+ src = fetchFromGitHub {
1010+ owner = "arminbiere";
1111+ repo = "kissat";
1212+ # https://github.com/arminbiere/kissat/issues/18
1313+ rev = "abfa45fb782fa3b7c6e2eb6b939febe74d7270b7";
1414+ sha256 = "06pbmkjxgf2idhsrd1yzvbxr2wf8l06pjb38bzbygm6n9ami89b8";
1515+ };
1616+1717+ outputs = [ "out" "dev" "lib" ];
1818+1919+ checkInputs = [ drat-trim p7zip ];
2020+ doCheck = true;
2121+2222+ # 'make test' assumes that /etc/passwd is not writable.
2323+ patches = [ ./writable-passwd-is-ok.patch ];
2424+2525+ # the configure script is not generated by autotools and does not accept the
2626+ # arguments that the default configurePhase passes like --prefix and --libdir
2727+ dontAddPrefix = true;
2828+ setOutputFlags = false;
2929+3030+ installPhase = ''
3131+ runHook preInstall
3232+3333+ install -Dm0755 build/kissat "$out/bin/kissat"
3434+ install -Dm0644 src/kissat.h "$dev/include/kissat.h"
3535+ install -Dm0644 build/libkissat.a "$lib/lib/libkissat.a"
3636+ mkdir -p "$out/share/doc/kissat/"
3737+ install -Dm0644 {LICEN?E,README*,VERSION} "$out/share/doc/kissat/"
3838+3939+ runHook postInstall
4040+ '';
4141+4242+ meta = with lib; {
4343+ description = "A 'keep it simple and clean bare metal SAT solver' written in C";
4444+ longDescription = ''
4545+ Kissat is a "keep it simple and clean bare metal SAT solver" written in C.
4646+ It is a port of CaDiCaL back to C with improved data structures,
4747+ better scheduling of inprocessing and optimized algorithms and implementation.
4848+ '';
4949+ maintainers = with maintainers; [ shnarazk ];
5050+ platforms = platforms.unix;
5151+ license = licenses.mit;
5252+ homepage = "http://fmv.jku.at/kissat";
5353+ };
5454+}
···2525, zlib
2626}:
27272828-# We need multiple binaries as a given binary isn't always able to build
2929-# (even slightly) older or newer versions.
3030-# - 0.26.1 can build 0.25.x and 0.26.x but not 0.27.x
3131-# - 0.27.2 can build 0.27.x but not 0.25.x, 0.26.x and 0.29.x
3232-#
3328# We need to keep around at least the latest version released with a stable
3429# NixOS
3530let
···241236 };
242237243238 crystal_1_2 = generic {
244244- version = "1.2.1";
245245- sha256 = "sha256-jyNmY3n+u8WoVqHY8B5H9Vr9Ix3RogCtm8irkXZ3aek=";
239239+ version = "1.2.2";
240240+ sha256 = "sha256-nyOXhsutVBRdtJlJHe2dALl//BUXD1JeeQPgHU4SwiU=";
246241 binary = crystal_1_1;
247242 };
248243
···379379 joseki = apache-jena-fuseki; # added 2016-02-28
380380 jvmci8 = throw "graalvm8 and its tools were deprecated in favor of graalvm8-ce"; # added 2021-10-15
381381 json_glib = json-glib; # added 2018-02-25
382382+ kafkacat = kcat; # added 2021-10-07
382383 kdecoration-viewer = throw "kdecoration-viewer has been removed from nixpkgs, as there is no upstream activity"; # 2020-06-16
383384 k9copy = throw "k9copy has been removed from nixpkgs, as there is no upstream activity"; # 2020-11-06
384385 kibana7-oss = throw "kibana7-oss has been removed, as the distribution is no longer provided by upstream. https://github.com/NixOS/nixpkgs/pull/114456"; # added 2021-06-09