···1# OCaml {#sec-language-ocaml}
2000000000000000000000000003OCaml 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`.
45Given 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`.
···1# OCaml {#sec-language-ocaml}
23+## User guide {#sec-language-ocaml-user-guide}
4+5+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`.
6+7+If you don't care about the exact compiler version, `ocamlPackages` is a top-level alias pointing to a recent version of OCaml.
8+9+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`.
10+11+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.
12+For example:
13+```nix
14+let
15+ pkgs = import <nixpkgs> {};
16+ # choose the ocaml version you want to use
17+ ocamlPackages = pkgs.ocaml-ng.ocamlPackages_4_12;
18+in
19+pkgs.mkShell {
20+ # build tools
21+ nativeBuildInputs = with ocamlPackages; [ ocaml findlib dune_2 ocaml-lsp ];
22+ # dependencies
23+ buildInputs = with ocamlPackages; [ ocamlgraph ];
24+}
25+```
26+27+## Packaging guide {#sec-language-ocaml-packaging}
28+29OCaml 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`.
3031Given 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`.
···1+{ lib, stdenv, fetchFromGitHub
2+, drat-trim, p7zip
3+}:
4+5+stdenv.mkDerivation rec {
6+ pname = "kissat";
7+ version = "2.0.1";
8+9+ src = fetchFromGitHub {
10+ owner = "arminbiere";
11+ repo = "kissat";
12+ # https://github.com/arminbiere/kissat/issues/18
13+ rev = "abfa45fb782fa3b7c6e2eb6b939febe74d7270b7";
14+ sha256 = "06pbmkjxgf2idhsrd1yzvbxr2wf8l06pjb38bzbygm6n9ami89b8";
15+ };
16+17+ outputs = [ "out" "dev" "lib" ];
18+19+ checkInputs = [ drat-trim p7zip ];
20+ doCheck = true;
21+22+ # 'make test' assumes that /etc/passwd is not writable.
23+ patches = [ ./writable-passwd-is-ok.patch ];
24+25+ # the configure script is not generated by autotools and does not accept the
26+ # arguments that the default configurePhase passes like --prefix and --libdir
27+ dontAddPrefix = true;
28+ setOutputFlags = false;
29+30+ installPhase = ''
31+ runHook preInstall
32+33+ install -Dm0755 build/kissat "$out/bin/kissat"
34+ install -Dm0644 src/kissat.h "$dev/include/kissat.h"
35+ install -Dm0644 build/libkissat.a "$lib/lib/libkissat.a"
36+ mkdir -p "$out/share/doc/kissat/"
37+ install -Dm0644 {LICEN?E,README*,VERSION} "$out/share/doc/kissat/"
38+39+ runHook postInstall
40+ '';
41+42+ meta = with lib; {
43+ description = "A 'keep it simple and clean bare metal SAT solver' written in C";
44+ longDescription = ''
45+ Kissat is a "keep it simple and clean bare metal SAT solver" written in C.
46+ It is a port of CaDiCaL back to C with improved data structures,
47+ better scheduling of inprocessing and optimized algorithms and implementation.
48+ '';
49+ maintainers = with maintainers; [ shnarazk ];
50+ platforms = platforms.unix;
51+ license = licenses.mit;
52+ homepage = "http://fmv.jku.at/kissat";
53+ };
54+}
···25, zlib
26}:
2728-# We need multiple binaries as a given binary isn't always able to build
29-# (even slightly) older or newer versions.
30-# - 0.26.1 can build 0.25.x and 0.26.x but not 0.27.x
31-# - 0.27.2 can build 0.27.x but not 0.25.x, 0.26.x and 0.29.x
32-#
33# We need to keep around at least the latest version released with a stable
34# NixOS
35let
···241 };
242243 crystal_1_2 = generic {
244- version = "1.2.1";
245- sha256 = "sha256-jyNmY3n+u8WoVqHY8B5H9Vr9Ix3RogCtm8irkXZ3aek=";
246 binary = crystal_1_1;
247 };
248
···25, zlib
26}:
270000028# We need to keep around at least the latest version released with a stable
29# NixOS
30let
···236 };
237238 crystal_1_2 = generic {
239+ version = "1.2.2";
240+ sha256 = "sha256-nyOXhsutVBRdtJlJHe2dALl//BUXD1JeeQPgHU4SwiU=";
241 binary = crystal_1_1;
242 };
243
···379 joseki = apache-jena-fuseki; # added 2016-02-28
380 jvmci8 = throw "graalvm8 and its tools were deprecated in favor of graalvm8-ce"; # added 2021-10-15
381 json_glib = json-glib; # added 2018-02-25
0382 kdecoration-viewer = throw "kdecoration-viewer has been removed from nixpkgs, as there is no upstream activity"; # 2020-06-16
383 k9copy = throw "k9copy has been removed from nixpkgs, as there is no upstream activity"; # 2020-11-06
384 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
···379 joseki = apache-jena-fuseki; # added 2016-02-28
380 jvmci8 = throw "graalvm8 and its tools were deprecated in favor of graalvm8-ce"; # added 2021-10-15
381 json_glib = json-glib; # added 2018-02-25
382+ kafkacat = kcat; # added 2021-10-07
383 kdecoration-viewer = throw "kdecoration-viewer has been removed from nixpkgs, as there is no upstream activity"; # 2020-06-16
384 k9copy = throw "k9copy has been removed from nixpkgs, as there is no upstream activity"; # 2020-11-06
385 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