koreader-from-src: inject tesseract sources via make args

This commit is contained in:
Colin 2024-03-22 17:58:41 +00:00
parent 96c330813f
commit 98073f5e19
2 changed files with 18 additions and 7 deletions

View File

@ -114,6 +114,15 @@ let
];
};
tesseract-src-ko = fetchFromGitHub {
# TODO: try using nixpkgs' tesseract.src (i doubt it will work)
owner = "tesseract-ocr";
repo = "tesseract";
name = "tesseract";
rev = "60176fc5ae5e7f6bdef60c926a4b5ea03de2bfa7";
hash = "sha256-FQvlrJ+Uy7+wtUxBuS5NdoToUwNRhYw2ju8Ya8MLyQw=";
};
# XXX: for some inscrutable reason, `enable52Compat` is *partially* broken, only when cross compiling.
# `table.unpack` is non-nil, but `table.pack` is nil.
# the normal path is for `enable52Compat` to set `env.NIX_CFLAGS_COMPILE = "-DLUAJIT_ENABLE_LUA52COMPAT";`
@ -303,6 +312,7 @@ let
PNG_DIR="${libAndDev libpng}" \
SQLITE_LIB="${lib.getLib sqlite}/lib/libsqlite3.so" \
SQLITE_DIR="${lib.getDev sqlite}" \
TESSERACT_DIR="$NIX_BUILD_TOP/tesseract" \
UTF8PROC_LIB="${lib.getLib utf8proc}/lib/libutf8proc.so" \
UTF8PROC_DIR="${utf8procAll}" \
ZLIB="${lib.getLib zlib}/lib/libz.so" \
@ -365,6 +375,7 @@ stdenv.mkDerivation rec {
srcs = [
src
leptonica-src-ko
tesseract-src-ko
] ++ (lib.mapAttrsToList
(name: src: fetchgit (
{
@ -417,7 +428,7 @@ stdenv.mkDerivation rec {
--replace-fail ' -rm ' ' # -rm'
# make some sources writable (only the `sourceRoot` is writable by default)
chmod -R u+w "$NIX_BUILD_TOP/leptonica"
chmod -R u+w "$NIX_BUILD_TOP"/{leptonica,tesseract}
# lots of places in Makefile.third (incorrectly) assume lib paths are relative to CURDIR,
# so link /nix into CURDIR to allow them to work anyway

View File

@ -281,12 +281,12 @@ in
# source.hash = "sha256-EyvljVXhOsdxIYOGTzD+T16nvW7/RNx3DuQ2OdhjXJ4=";
# package = sdcv;
# };
tesseract = {
source.url = "https://github.com/tesseract-ocr/tesseract.git";
source.rev = "60176fc5ae5e7f6bdef60c926a4b5ea03de2bfa7";
source.hash = "sha256-FQvlrJ+Uy7+wtUxBuS5NdoToUwNRhYw2ju8Ya8MLyQw=";
# package = tesseract; # i guess koreader's k2pdf also builds tessearct??
};
# tesseract = {
# source.url = "https://github.com/tesseract-ocr/tesseract.git";
# source.rev = "60176fc5ae5e7f6bdef60c926a4b5ea03de2bfa7";
# source.hash = "sha256-FQvlrJ+Uy7+wtUxBuS5NdoToUwNRhYw2ju8Ya8MLyQw=";
# # package = tesseract; # i guess koreader's k2pdf also builds tessearct??
# };
turbo = {
source.url = "https://github.com/kernelsauce/turbo";
source.rev = "tags/v2.1.3";