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