diff options
author | aszlig <aszlig@redmoonstudios.org> | 2017-04-07 23:05:04 +0200 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2017-04-11 03:21:26 +0200 |
commit | 288a79187cdb6e92c8354b3e06cebbdc8ad65d4a (patch) | |
tree | 3a1f4ef6f06c7bf887e157fa1a041df678f3b4e6 /pkgs/applications/graphics/tesseract | |
parent | c8c340b05ac2ebef9e963c89b168d5053ae57dec (diff) | |
download | nixpkgs-288a79187cdb6e92c8354b3e06cebbdc8ad65d4a.tar nixpkgs-288a79187cdb6e92c8354b3e06cebbdc8ad65d4a.tar.gz nixpkgs-288a79187cdb6e92c8354b3e06cebbdc8ad65d4a.tar.bz2 nixpkgs-288a79187cdb6e92c8354b3e06cebbdc8ad65d4a.tar.lz nixpkgs-288a79187cdb6e92c8354b3e06cebbdc8ad65d4a.tar.xz nixpkgs-288a79187cdb6e92c8354b3e06cebbdc8ad65d4a.tar.zst nixpkgs-288a79187cdb6e92c8354b3e06cebbdc8ad65d4a.zip |
tesseract: Reintroduce enableLanguages
I've removed that attribute in 68bc260ca2d71a676dd6afdb3524d4fff483016b, because the language files no longer were distributed as seperate files, but if we for example only want to use the English training data, the closure size of Tesseract gets quite large (around 1.2 GB), which is a bit much just to be able to run NixOS VM tests. For this reason I've also switched the VM tests back to using only the English language. Tested using the following VM tests (the ones that have OCR enabled) on x86_64-linux: * nixos/tests/chromium.nix -A stable * nixos/tests/emacs-daemon.nix * nixos/tests/installer.nix -A luksroot * nixos/tests/lightdm.nix * nixos/tests/plasma5.nix * nixos/tests/sddm.nix Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs/applications/graphics/tesseract')
-rw-r--r-- | pkgs/applications/graphics/tesseract/default.nix | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/pkgs/applications/graphics/tesseract/default.nix b/pkgs/applications/graphics/tesseract/default.nix index 1f1da9a389f..b5e1707c4fe 100644 --- a/pkgs/applications/graphics/tesseract/default.nix +++ b/pkgs/applications/graphics/tesseract/default.nix @@ -1,5 +1,8 @@ { stdenv, fetchFromGitHub, pkgconfig, leptonica, libpng, libtiff , icu, pango, opencl-headers + +# Supported list of languages or `null' for all available languages +, enableLanguages ? null }: stdenv.mkDerivation rec { @@ -25,7 +28,30 @@ stdenv.mkDerivation rec { LIBLEPT_HEADERSDIR = "${leptonica}/include"; - postInstall = "cp -Rt \"$out/share/tessdata\" \"$tessdata/\"*"; + # Copy the .traineddata files of the languages specified in enableLanguages + # into `$out/share/tessdata' and check afterwards if copying was successful. + postInstall = let + mkArg = lang: "-iname ${stdenv.lib.escapeShellArg "${lang}.traineddata"}"; + mkFindArgs = stdenv.lib.concatMapStringsSep " -o " mkArg; + findLangArgs = if enableLanguages != null + then "\\( ${mkFindArgs enableLanguages} \\)" + else "-iname '*.traineddata'"; + in '' + numLangs="$(find "$tessdata" -mindepth 1 -maxdepth 1 -type f \ + ${findLangArgs} -exec cp -t "$out/share/tessdata" {} + -print | wc -l)" + + ${if enableLanguages != null then '' + expected=${toString (builtins.length enableLanguages)} + '' else '' + expected="$(ls -1 "$tessdata/"*.traineddata | wc -l)" + ''} + + if [ "$numLangs" -ne "$expected" ]; then + echo "Expected $expected languages, but $numLangs" \ + "were copied to \`$out/share/tessdata'" >&2 + exit 1 + fi + ''; meta = { description = "OCR engine"; |