nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromGitHub
4, runCommand
5, dieHook
6, cmake
7, icu
8, boost
9}:
10
11let cg3 = stdenv.mkDerivation rec {
12 pname = "cg3";
13 version = "1.3.9";
14
15 src = fetchFromGitHub {
16 owner = "GrammarSoft";
17 repo = "${pname}";
18 rev = "v${version}";
19 sha256 = "sha256-TiEhhk90w5GibGZ4yalIf+4qLA8NoU6+GIPN6QNTz2A=";
20 };
21
22 nativeBuildInputs = [
23 cmake
24 ];
25
26 buildInputs = [
27 icu
28 boost
29 ];
30
31 doCheck = true;
32
33 postFixup = ''
34 substituteInPlace "$out"/lib/pkgconfig/cg3.pc \
35 --replace '=''${prefix}//' '=/'
36 '';
37
38 passthru.tests.minimal = runCommand "${pname}-test" {
39 buildInputs = [
40 cg3
41 dieHook
42 ];
43 } ''
44 echo 'DELIMITERS = "."; ADD (tag) (*);' >grammar.cg3
45 printf '"<a>"\n\t"a" tag\n\n' >want.txt
46 printf '"<a>"\n\t"a"\n\n' | vislcg3 -g grammar.cg3 >got.txt
47 diff -s want.txt got.txt || die "Grammar application did not produce expected parse"
48 touch $out
49 '';
50
51
52 # TODO, consider optionals:
53 # - Enable tcmalloc unless darwin?
54 # - Enable python bindings?
55
56 meta = with lib; {
57 homepage = "https://github.com/GrammarSoft/cg3";
58 description = "Constraint Grammar interpreter, compiler and applicator vislcg3";
59 maintainers = with maintainers; [ unhammer ];
60 license = licenses.gpl3Plus;
61 platforms = platforms.all;
62 };
63};
64
65in
66 cg3