nur-packages

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

default.nix (2539B)


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