default.nix (2403B)
1 { lib, stdenv, fetchurl, qmake, unzip, leptonica, tesseract4, wrapQtAppsHook }: 2 3 stdenv.mkDerivation rec { 4 pname = "capture2text"; 5 version = "4.6.2"; 6 7 src = fetchurl { 8 url = "mirror://sourceforge/capture2text/SourceCode/Capture2Text_v${version}/Capture2Text_v${version}_Source_Code.zip"; 9 hash = "sha256-FeQ5E2lW+QOcg6Qi1I75W4BkQmfDiZtJ7+U2K08Ji2U="; 10 }; 11 12 postPatch = '' 13 substituteInPlace Capture2Text.pro \ 14 --replace "QMAKE_CXXFLAGS" "#QMAKE_CXXFLAGS" \ 15 --replace "-lpvt.cppan.demo.danbloomberg.leptonica-1.74.4" "-llept" \ 16 --replace "-luser32" "-ltesseract" 17 18 # Fix app description 19 substituteInPlace CommandLine.cpp \ 20 --replace "Capture2Text_CLI.exe" "capture2text" 21 22 # Locate dictionaries in $XDG_DATA_DIR/Capture2Text/Capture2Text/tessdata 23 # Initialize tesseract without specifying tessdata path 24 sed -i '1 i #include <QStandardPaths>' OcrEngine.cpp 25 substituteInPlace OcrEngine.cpp \ 26 --replace "QCoreApplication::applicationDirPath()" \ 27 "QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)" \ 28 --replace "exeDirpath.toLocal8Bit().constData()" "NULL" 29 30 # See https://github.com/DanBloomberg/leptonica/commit/990a76de210636dfc4c976c7d3c6d63500e363b9 31 substituteInPlace PreProcess.cpp \ 32 --replace "pixAverageInRect(binarizeForNegPixs, &negRect, &pixelAvg)" \ 33 "pixAverageInRect(binarizeForNegPixs, NULL, &negRect, 0, 255, 1, &pixelAvg)" 34 ''; 35 36 buildInputs = [ leptonica tesseract4 ]; 37 38 nativeBuildInputs = [ qmake unzip wrapQtAppsHook ]; 39 40 qmakeFlags = [ 41 "CONFIG+=console" 42 "INCLUDEPATH+=${leptonica}/include/leptonica" 43 "INCLUDEPATH+=${tesseract4}/include/tesseract" 44 ]; 45 46 installPhase = if stdenv.isDarwin then '' 47 mkdir -p $out/Applications $out/bin 48 mv Capture2Text_CLI.app $out/Applications 49 ln -s $out/Applications/Capture2Text_CLI.app/Contents/MacOS/Capture2Text_CLI $out/bin/capture2text 50 '' else '' 51 install -Dm755 Capture2Text_CLI -t $out/bin 52 ln -s $out/bin/Capture2Text_CLI $out/bin/capture2text 53 ''; 54 55 meta = with lib; { 56 description = "Capture2Text enables users to quickly OCR a portion of the screen using a keyboard shortcut"; 57 homepage = "http://capture2text.sourceforge.net/"; 58 license = licenses.gpl3Plus; 59 maintainers = [ maintainers.sikmir ]; 60 platforms = platforms.unix; 61 broken = true; 62 }; 63 }