Merge pull request #236313 from NixOS/kaldi-fix

kaldi: fix build

authored by Jan Tojnar and committed by GitHub 65dbea59 88f3aca0

+46 -47
+46 -47
pkgs/tools/audio/kaldi/default.nix
··· 3 , openblas 4 , blas 5 , lapack 6 - , openfst 7 , icu 8 , cmake 9 , pkg-config ··· 11 , git 12 , python3 13 , Accelerate 14 }: 15 16 assert 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 { 27 pname = "kaldi"; 28 - version = "unstable-2022-09-26"; 29 30 src = fetchFromGitHub { 31 owner = "kaldi-asr"; 32 repo = "kaldi"; 33 - rev = "f6f4ccaf213f0fe8b26e633a7dc0c802150626a0"; 34 - sha256 = "sha256-ybW2J4lWf6YaQGZZvxEVDUMAg84DC17W+yX6ZsuBDac="; 35 }; 36 37 cmakeFlags = [ ··· 39 "-DBUILD_SHARED_LIBS=on" 40 "-DBLAS_LIBRARIES=-lblas" 41 "-DLAPACK_LIBRARIES=-llapack" 42 ]; 43 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 - 75 buildInputs = [ 76 openblas 77 - openfst 78 icu 79 ] ++ lib.optionals stdenv.isDarwin [ 80 Accelerate ··· 86 python3 87 ]; 88 89 postInstall = '' 90 mkdir -p $out/share/kaldi 91 cp -r ../egs $out/share/kaldi 92 ''; 93 94 meta = with lib; { 95 description = "Speech Recognition Toolkit"; 96 homepage = "https://kaldi-asr.org"; ··· 98 maintainers = with maintainers; [ mic92 ]; 99 platforms = platforms.unix; 100 }; 101 - }
··· 3 , openblas 4 , blas 5 , lapack 6 , icu 7 , cmake 8 , pkg-config ··· 10 , git 11 , python3 12 , Accelerate 13 + , _experimental-update-script-combinators 14 + , common-updater-scripts 15 + , ripgrep 16 + , unstableGitUpdater 17 + , writeShellScript 18 }: 19 20 assert blas.implementation == "openblas" && lapack.implementation == "openblas"; 21 + stdenv.mkDerivation (finalAttrs: { 22 pname = "kaldi"; 23 + version = "unstable-2023-05-02"; 24 25 src = fetchFromGitHub { 26 owner = "kaldi-asr"; 27 repo = "kaldi"; 28 + rev = "71f38e62cad01c3078555bfe78d0f3a527422d75"; 29 + sha256 = "sha256-2xm0F80cjovy/G9Ytq/iwa1eexZk0mromv6PPuNIT8U="; 30 }; 31 32 cmakeFlags = [ ··· 34 "-DBUILD_SHARED_LIBS=on" 35 "-DBLAS_LIBRARIES=-lblas" 36 "-DLAPACK_LIBRARIES=-llapack" 37 + "-DFETCHCONTENT_SOURCE_DIR_OPENFST:PATH=${finalAttrs.passthru.sources.openfst}" 38 ]; 39 40 buildInputs = [ 41 openblas 42 icu 43 ] ++ lib.optionals stdenv.isDarwin [ 44 Accelerate ··· 50 python3 51 ]; 52 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 + 63 postInstall = '' 64 mkdir -p $out/share/kaldi 65 cp -r ../egs $out/share/kaldi 66 ''; 67 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 + 93 meta = with lib; { 94 description = "Speech Recognition Toolkit"; 95 homepage = "https://kaldi-asr.org"; ··· 97 maintainers = with maintainers; [ mic92 ]; 98 platforms = platforms.unix; 99 }; 100 + })