summary refs log tree commit diff
path: root/pkgs/applications/science/logic/acgtk/default.nix
blob: b787a4e7a01ce6749c8d37a5c6877e34cade6b75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ stdenv, fetchurl, ocamlPackages,
  buildBytecode ? true,
  buildNative ? true,
  installExamples ? true,
  installEmacsMode ? true }:

let inherit (stdenv.lib) versionAtLeast optionalString; in

let inherit (ocamlPackages) ocaml camlp4; in

assert buildBytecode || buildNative;

stdenv.mkDerivation {

  name = "acgtk-1.3.1";

  src = fetchurl {
    url = http://calligramme.loria.fr/acg/software/acg-1.3.1-20170303.tar.gz;
    sha256 = "1hhrf6bx2x2wbv5ldn4fnxhpr9lyrj3zh1vcnx8wf8f06ih4rzfq";
  };

  buildInputs = with ocamlPackages; [
    ocaml findlib camlp4 ansiterminal biniou bolt cairo2 dypgen easy-format ocf yojson
  ];

  patches = [ ./install-emacs-to-site-lisp.patch
              ./use-nix-ocaml-byteflags.patch ];

  postPatch = optionalString (camlp4 != null) ''
    substituteInPlace src/Makefile.master.in \
      --replace "+camlp4" "${camlp4}/lib/ocaml/${ocaml.version}/site-lib/camlp4/"
  '' + optionalString (versionAtLeast (stdenv.lib.getVersion ocamlPackages.yojson) "1.4") ''
    substituteInPlace src/scripting/Makefile.in --replace yojson.cmo yojson.cma
  '';

  # The bytecode executable is dependent on the dynamic library provided by
  # ANSITerminal. We can use the -dllpath flag of ocamlc (analogous to
  # -rpath) to make sure that ocamlrun is able to link the library at
  # runtime and that Nix detects a runtime dependency.
  NIX_OCAML_BYTEFLAGS = "-dllpath ${ocamlPackages.ansiterminal}/lib/ocaml/${ocaml.version}/site-lib/ANSITerminal";

  buildFlags = optionalString buildBytecode "byte"
             + " "
             + optionalString buildNative "opt";

  installTargets = "install"
                 + " " + optionalString installExamples "install-examples"
                 + " " + optionalString installEmacsMode "install-emacs";

  meta = with stdenv.lib; {
    homepage = http://calligramme.loria.fr/acg/;
    description = "A toolkit for developing ACG signatures and lexicon";
    license = licenses.cecill20;
    platforms = ocaml.meta.platforms or [];
    maintainers = [ maintainers.jirkamarsik ];
  };
}