nur-packages

My NUR packages
git clone git://git.sikmir.ru/nur-packages
Log | Files | Refs | README | LICENSE

package.nix (2559B)


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