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