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