33, openblas
44, blas
55, lapack
6- , openfst
76, icu
87, cmake
98, pkg-config
109, fetchFromGitHub
1110, git
1211, python3
1312, Accelerate
13+ , _experimental-update-script-combinators
14+ , common-updater-scripts
15+ , ripgrep
16+ , unstableGitUpdater
17+ , writeShellScript
1418} :
1519
1620assert blas . implementation == "openblas" && lapack . implementation == "openblas" ;
17- let
18- # rev from https://github.com/kaldi-asr/kaldi/blob/master/cmake/third_party/openfst.cmake
19- openfst = fetchFromGitHub {
20- owner = "kkm000" ;
21- repo = "openfst" ;
22- rev = "338225416178ac36b8002d70387f5556e44c8d05" ;
23- sha256 = "sha256-MGEUuw7ex+WcujVdxpO2Bf5sB6Z0edcAeLGqW/Lo1Hs=" ;
24- } ;
25- in
26- stdenv . mkDerivation {
21+ stdenv . mkDerivation ( finalAttrs : {
2722 pname = "kaldi" ;
28- version = "unstable-2022-09-26 " ;
23+ version = "unstable-2023-05-02 " ;
2924
3025 src = fetchFromGitHub {
3126 owner = "kaldi-asr" ;
3227 repo = "kaldi" ;
33- rev = "f6f4ccaf213f0fe8b26e633a7dc0c802150626a0 " ;
34- sha256 = "sha256-ybW2J4lWf6YaQGZZvxEVDUMAg84DC17W+yX6ZsuBDac =" ;
28+ rev = "71f38e62cad01c3078555bfe78d0f3a527422d75 " ;
29+ sha256 = "sha256-2xm0F80cjovy/G9Ytq/iwa1eexZk0mromv6PPuNIT8U =" ;
3530 } ;
3631
3732 cmakeFlags = [
3833 "-DKALDI_BUILD_TEST=off"
3934 "-DBUILD_SHARED_LIBS=on"
4035 "-DBLAS_LIBRARIES=-lblas"
4136 "-DLAPACK_LIBRARIES=-llapack"
37+ "-DFETCHCONTENT_SOURCE_DIR_OPENFST:PATH=${ finalAttrs . passthru . sources . openfst } "
4238 ] ;
4339
44- enableParallelBuilding = true ;
45-
46- preConfigure = ''
47- mkdir bin
48- cat > bin/git <<'EOF'
49- #!${ stdenv . shell }
50- if [[ "$1" == "--version" ]]; then
51- # cmake checks this
52- ${ git } /bin/git --version
53- elif [[ "$1" == "clone" ]]; then
54- # mock this call:
55-
56- # https://github.com/kaldi-asr/kaldi/blob/c9d8b9ad3fef89237ba5517617d977b7d70a7ed5/cmake/third_party/openfst.cmake#L5
57- cp -r ${ openfst } '' ${@: -1}
58- chmod -R +w '' ${@: -1}
59- elif [[ "$1" == "rev-list" ]]; then
60- # fix up this call:
61- # https://github.com/kaldi-asr/kaldi/blob/c9d8b9ad3fef89237ba5517617d977b7d70a7ed5/cmake/VersionHelper.cmake#L8
62- echo 0
63- elif [[ "$1" == "rev-parse" ]]; then
64- echo ${ openfst . rev }
65- echo 0
66- fi
67- true
68- EOF
69- chmod +x bin/git
70- export PATH=$(pwd)/bin:$PATH
71- '' ;
72-
73- outputs = [ "out" "dev" ] ;
74-
7540 buildInputs = [
7641 openblas
77- openfst
7842 icu
7943 ] ++ lib . optionals stdenv . isDarwin [
8044 Accelerate
@@ -86,16 +50,51 @@ stdenv.mkDerivation {
8650 python3
8751 ] ;
8852
53+ preConfigure = ''
54+ cmakeFlagsArray+=(
55+ # Extract version without the need for git.
56+ # https://github.com/kaldi-asr/kaldi/blob/71f38e62cad01c3078555bfe78d0f3a527422d75/cmake/VersionHelper.cmake
57+ # Patch number is not actually used by default so we can just ignore it.
58+ # https://github.com/kaldi-asr/kaldi/blob/71f38e62cad01c3078555bfe78d0f3a527422d75/CMakeLists.txt#L214
59+ "-DKALDI_VERSION=$(cat src/.version)"
60+ )
61+ '' ;
62+
8963 postInstall = ''
9064 mkdir -p $out/share/kaldi
9165 cp -r ../egs $out/share/kaldi
9266 '' ;
9367
68+ passthru = {
69+ sources = {
70+ # rev from https://github.com/kaldi-asr/kaldi/blob/master/cmake/third_party/openfst.cmake
71+ openfst = fetchFromGitHub {
72+ owner = "kkm000" ;
73+ repo = "openfst" ;
74+ rev = "338225416178ac36b8002d70387f5556e44c8d05" ;
75+ hash = "sha256-MGEUuw7ex+WcujVdxpO2Bf5sB6Z0edcAeLGqW/Lo1Hs=" ;
76+ } ;
77+ } ;
78+
79+ updateScript =
80+ let
81+ updateSource = unstableGitUpdater { } ;
82+ updateOpenfst = writeShellScript "update-openfst" ''
83+ hash=$(${ ripgrep } /bin/rg --multiline --pcre2 --only-matching 'FetchContent_Declare\(\s*openfst[^)]*GIT_TAG\s*([0-9a-f]{40})' --replace '$1' "${ finalAttrs . src } /cmake/third_party/openfst.cmake")
84+ ${ common-updater-scripts } /bin/update-source-version kaldi.sources.openfst "$hash" --source-key=out "--version-key=rev"
85+ '' ;
86+ in
87+ _experimental-update-script-combinators . sequence [
88+ updateSource
89+ updateOpenfst
90+ ] ;
91+ } ;
92+
9493 meta = with lib ; {
9594 description = "Speech Recognition Toolkit" ;
9695 homepage = "https://kaldi-asr.org" ;
9796 license = licenses . mit ;
9897 maintainers = with maintainers ; [ mic92 ] ;
9998 platforms = platforms . unix ;
10099 } ;
101- }
100+ } )
0 commit comments