Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1/* Topkg is a packager for distributing OCaml software. This derivation
2provides facilities to describe derivations for OCaml libraries
3using topkg.
4The `buildPhase` and `installPhase` attributes can be reused directly
5in many cases. When more fine-grained control on how to run the “topkg”
6build system is required, the attribute `run` can be used.
7*/
8{ stdenv, lib, fetchurl, ocaml, findlib, ocamlbuild, result, opaline }:
9
10let
11 param =
12 if lib.versionAtLeast ocaml.version "4.05" then {
13 version = "1.0.5";
14 sha256 = "sha256-RSCCYm5lGsSxYzwrSuTK16vrH7ahMEbmmfle7Fi10cc=";
15 } else if lib.versionAtLeast ocaml.version "4.03" then {
16 version = "1.0.3";
17 sha256 = "0b77gsz9bqby8v77kfi4lans47x9p2lmzanzwins5r29maphb8y6";
18 } else {
19 version = "1.0.0";
20 sha256 = "1df61vw6v5bg2mys045682ggv058yqkqb67w7r2gz85crs04d5fw";
21 propagatedBuildInputs = [ result ];
22 };
23
24/* This command allows to run the “topkg” build system.
25 * It is usually called with `build` or `test` as argument.
26 * Packages that use `topkg` may call this command as part of
27 * their `buildPhase` or `checkPhase`.
28*/
29 run = "ocaml -I ${findlib}/lib/ocaml/${ocaml.version}/site-lib/ pkg/pkg.ml";
30in
31
32stdenv.mkDerivation rec {
33 pname = "ocaml${ocaml.version}-topkg";
34 inherit (param) version;
35
36 src = fetchurl {
37 url = "https://erratique.ch/software/topkg/releases/topkg-${version}.tbz";
38 inherit (param) sha256;
39 };
40
41 nativeBuildInputs = [ ocaml findlib ocamlbuild ];
42 propagatedBuildInputs = param.propagatedBuildInputs or [];
43
44 strictDeps = true;
45
46 buildPhase = "${run} build";
47 createFindlibDestdir = true;
48 installPhase = "${opaline}/bin/opaline -prefix $out -libdir $OCAMLFIND_DESTDIR";
49
50 passthru = { inherit run; };
51
52 meta = {
53 homepage = "https://erratique.ch/software/topkg";
54 license = lib.licenses.isc;
55 maintainers = [ lib.maintainers.vbgl ];
56 description = "A packager for distributing OCaml software";
57 inherit (ocaml.meta) platforms;
58 };
59}