about summary refs log tree commit diff
path: root/pkgs/development/interpreters/cg3
diff options
context:
space:
mode:
authorKevin Brubeck Unhammer <unhammer@fsfe.org>2022-08-03 11:48:22 +0200
committerKevin Brubeck Unhammer <unhammer@fsfe.org>2022-08-24 10:01:49 +0200
commit44cf3379a246449adb150ab7143798d31f9cb925 (patch)
treeb829bfbad72188a558776eb12748bc2de475072b /pkgs/development/interpreters/cg3
parent76cab430e4d797582168fa93c347cb3c5d1e16b9 (diff)
cg3: init at version 1.3.7
Diffstat (limited to 'pkgs/development/interpreters/cg3')
-rw-r--r--pkgs/development/interpreters/cg3/default.nix61
1 files changed, 61 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/cg3/default.nix b/pkgs/development/interpreters/cg3/default.nix
new file mode 100644
index 0000000000000..27db9bebcd0ca
--- /dev/null
+++ b/pkgs/development/interpreters/cg3/default.nix
@@ -0,0 +1,61 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, runCommand
+, dieHook
+, cmake
+, icu
+, boost
+}:
+
+let cg3 = stdenv.mkDerivation rec {
+  pname = "cg3";
+  version = "1.3.7";
+
+  src = fetchFromGitHub {
+    owner = "GrammarSoft";
+    repo = "${pname}";
+    rev = "v${version}";
+    sha256 = "Ena3dGoZsXOIY6mbvnfI0H7QqRifoxWIBKQrK3yQSmY=";
+  };
+
+  nativeBuildInputs = [
+    cmake
+  ];
+
+  buildInputs = [
+    icu
+    boost
+  ];
+
+  doCheck = true;
+
+  passthru.tests.minimal = runCommand "${pname}-test" {
+      buildInputs = [
+        cg3
+        dieHook
+      ];
+    } ''
+      echo 'DELIMITERS = "."; ADD (tag) (*);' >grammar.cg3
+      printf '"<a>"\n\t"a" tag\n\n' >want.txt
+      printf '"<a>"\n\t"a"\n\n' | vislcg3 -g grammar.cg3 >got.txt
+      diff -s want.txt got.txt || die "Grammar application did not produce expected parse"
+      touch $out
+    '';
+
+
+  # TODO, consider optionals:
+  # - Enable tcmalloc unless darwin?
+  # - Enable python bindings?
+
+  meta = with lib; {
+    homepage = "https://github.com/GrammarSoft/cg3";
+    description = "Constraint Grammar interpreter, compiler and applicator vislcg3";
+    maintainers = with maintainers; [ unhammer ];
+    license = licenses.gpl3Plus;
+    platforms = platforms.all;
+  };
+};
+
+in
+  cg3