nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 pkg-config,
6 wrapGAppsHook3,
7 intltool,
8 itstool,
9 libxml2,
10 gobject-introspection,
11 gtk3,
12 goocanvas_2,
13 gtkspell3,
14 isocodes,
15 python3,
16 tesseract4,
17 extraOcrEngines ? [ ], # other supported engines are: ocrad gocr cuneiform
18}:
19
20stdenv.mkDerivation (finalAttrs: {
21 pname = "ocrfeeder";
22 version = "0.8.5";
23
24 src = fetchurl {
25 url = "mirror://gnome/sources/ocrfeeder/${lib.versions.majorMinor finalAttrs.version}/ocrfeeder-${finalAttrs.version}.tar.xz";
26 hash = "sha256-sD0qWUndguJzTw0uy0FIqupFf4OX6dTFvcd+Mz+8Su0=";
27 };
28
29 nativeBuildInputs = [
30 pkg-config
31 wrapGAppsHook3
32 intltool
33 itstool
34 libxml2
35 gobject-introspection
36 ];
37
38 postPatch = ''
39 substituteInPlace configure \
40 --replace-fail "import imp" "import importlib.util" \
41 --replace-fail "imp.find_module" "importlib.util.find_spec" \
42 --replace-fail "distutils" "setuptools._distutils"
43 '';
44
45 buildInputs = [
46 gtk3
47 goocanvas_2
48 gtkspell3
49 isocodes
50 (python3.withPackages (
51 ps: with ps; [
52 pyenchant
53 sane
54 pillow
55 reportlab
56 odfpy
57 pygobject3
58 standard-imghdr
59 ]
60 ))
61 ];
62 patches = [
63 # Compiles, but doesn't launch without this, see:
64 # https://gitlab.gnome.org/GNOME/ocrfeeder/-/issues/83
65 ./fix-launch.diff
66 ];
67
68 enginesPath = lib.makeBinPath (
69 [
70 tesseract4
71 ]
72 ++ extraOcrEngines
73 );
74
75 preFixup = ''
76 gappsWrapperArgs+=(--prefix PATH : "${finalAttrs.enginesPath}")
77 gappsWrapperArgs+=(--set ISO_CODES_DIR "${isocodes}/share/xml/iso-codes")
78 '';
79
80 meta = {
81 homepage = "https://gitlab.gnome.org/GNOME/ocrfeeder";
82 description = "Complete Optical Character Recognition and Document Analysis and Recognition program";
83 maintainers = with lib.maintainers; [ doronbehar ];
84 license = lib.licenses.gpl3Plus;
85 platforms = lib.platforms.linux;
86 };
87})