Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv, fetchurl, fetchFromGitHub, ocaml, findlib, pkg-config, gtk2, libgnomecanvas, gtksourceview
2, camlp-streams, gnumake42
3}:
4
5let param =
6 let check = lib.versionAtLeast ocaml.version; in
7 if check "4.06" then rec {
8 version = "2.18.13";
9 src = fetchFromGitHub {
10 owner = "garrigue";
11 repo = "lablgtk";
12 rev = version;
13 sha256 = "sha256-69Svno0qLaUifMscnVuPUJlCo9d8Lee+1qiYx34G3Po=";
14 };
15 env = { };
16 buildInputs = [ camlp-streams ];
17 } else if check "3.12" then {
18 version = "2.18.5";
19 src = fetchurl {
20 url = "https://forge.ocamlcore.org/frs/download.php/1627/lablgtk-2.18.5.tar.gz";
21 sha256 = "0cyj6sfdvzx8hw7553lhgwc0krlgvlza0ph3dk9gsxy047dm3wib";
22 };
23 # Workaround build failure on -fno-common toolchains like upstream
24 # gcc-10. Otherwise build fails as:
25 # ld: ml_gtktree.o:(.bss+0x0): multiple definition of
26 # `ml_table_extension_events'; ml_gdkpixbuf.o:(.bss+0x0): first defined here
27 env.NIX_CFLAGS_COMPILE = "-fcommon";
28 } else throw "lablgtk is not available for OCaml ${ocaml.version}";
29in
30
31stdenv.mkDerivation {
32 pname = "ocaml${ocaml.version}-lablgtk";
33 inherit (param) version src env;
34
35 # gnumake42: https://github.com/garrigue/lablgtk/issues/162
36 nativeBuildInputs = [ pkg-config ocaml findlib gnumake42 ];
37 buildInputs = [ gtk2 libgnomecanvas gtksourceview ]
38 ++ param.buildInputs or [];
39
40 configureFlags = [ "--with-libdir=$(out)/lib/ocaml/${ocaml.version}/site-lib" ];
41 buildFlags = [ "world" ];
42
43 preInstall = ''
44 mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib
45 export OCAMLPATH=$out/lib/ocaml/${ocaml.version}/site-lib/:$OCAMLPATH
46 '';
47
48 dontStrip = true;
49
50 meta = with lib; {
51 description = "An OCaml interface to GTK";
52 homepage = "http://lablgtk.forge.ocamlcore.org/";
53 license = licenses.lgpl21Plus;
54 maintainers = with maintainers; [ maggesi roconnor vbgl ];
55 mainProgram = "lablgtk2";
56 inherit (ocaml.meta) platforms;
57 };
58}