1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, scikit-build
5, cmake
6, ush
7, requests
8, six
9, numpy
10, cffi
11, openfst
12, substituteAll
13, callPackage
14}:
15
16#
17# Maintainer note: only in-tree dependant is `dragonfly`, try to
18# update the two alongside eachother.
19#
20
21let
22 kaldi = callPackage ./fork.nix { };
23in
24buildPythonPackage rec {
25 pname = "kaldi-active-grammar";
26 version = "3.1.0";
27
28 src = fetchFromGitHub {
29 owner = "daanzu";
30 repo = pname;
31 rev = "v${version}";
32 sha256 = "0lilk6yjzcy31avy2z36bl9lr60gzwhmyqwqn8akq11qc3mbffsk";
33 };
34
35 KALDI_BRANCH = "foo";
36 KALDIAG_SETUP_RAW = "1";
37
38 patches = [
39 # Makes sure scikit-build doesn't try to build the dependencies for us
40 ./0001-stub.patch
41 # Uses the dependencies' binaries from $PATH instead of a specific directory
42 ./0002-exec-path.patch
43 # Makes it dynamically link to the correct Kaldi library
44 (substituteAll {
45 src = ./0003-ffi-path.patch;
46 kaldiFork = "${kaldi}/lib";
47 })
48 ];
49
50 # scikit-build puts us in the wrong folder. That is bad.
51 preBuild = ''
52 cd ..
53 '';
54
55 buildInputs = [ openfst kaldi ];
56 nativeBuildInputs = [ scikit-build cmake ];
57 propagatedBuildInputs = [ ush requests numpy cffi six ];
58
59 doCheck = false; # no tests exist
60
61 meta = with lib; {
62 description = "Python Kaldi speech recognition";
63 homepage = "https://github.com/daanzu/kaldi-active-grammar";
64 license = licenses.agpl3Plus;
65 maintainers = with maintainers; [ ckie ];
66 # Other platforms are supported upstream.
67 platforms = platforms.linux;
68 };
69}