From 268fce0c74222d4c470953c33c37cfed165fed1e Mon Sep 17 00:00:00 2001 From: Patrick Date: Sun, 7 Sep 2025 14:52:52 +0200 Subject: [PATCH] tesseract: fix passthru override --- .../graphics/tesseract/wrapper.nix | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/pkgs/applications/graphics/tesseract/wrapper.nix b/pkgs/applications/graphics/tesseract/wrapper.nix index 8ac5058ceebc..bcf38d2ab29c 100644 --- a/pkgs/applications/graphics/tesseract/wrapper.nix +++ b/pkgs/applications/graphics/tesseract/wrapper.nix @@ -58,34 +58,42 @@ let passthru = { inherit tesseractBase languages tessdata; }; # Only run test when all languages are available - test = lib.optionalAttrs (enableLanguages == null) { - tests.default = - runCommand "tesseract-test-ocr" - { - buildInputs = [ - tesseractWithData - imagemagick - ]; - } - '' - text="hello nix" + test = + runCommand "tesseract-test-ocr" + { + buildInputs = [ + tesseractWithData + imagemagick + ]; + } + '' + text="hello nix" - convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 \ - -fill black -annotate +5+20 "$text" /tmp/test-img.png 2>/dev/null - ocrResult=$(tesseract /tmp/test-img.png - | tr -d "\f") + convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 \ + -fill black -annotate +5+20 "$text" /tmp/test-img.png 2>/dev/null + ocrResult=$(tesseract /tmp/test-img.png - | tr -d "\f") - if [[ $ocrResult != $text ]]; then - echo "OCR test failed" - echo "expected: '$text'" - echo "actual: '$ocrResult'" - exit 1 - fi - touch $out - ''; - }; + if [[ $ocrResult != $text ]]; then + echo "OCR test failed" + echo "expected: '$text'" + echo "actual: '$ocrResult'" + exit 1 + fi + touch $out + ''; tesseract = - (if enableLanguages == [ ] then tesseractBase else tesseractWithData) // passthru // test; + (if enableLanguages == [ ] then tesseractBase else tesseractWithData).overrideAttrs + (old: { + passthru = + (old.passthru or { }) + // passthru + // lib.optionalAttrs (enableLanguages == null) { + tests = (old.passthru.tests or { }) // { + default = test; + }; + }; + }); in if enableLanguagesHash == null then tesseract