1 { lib, fetchurl, perlPackages, wrapGAppsHook, fetchpatch,
3 librsvg, sane-backends, sane-frontends,
5 imagemagick, libtiff, djvulibre, poppler_utils, ghostscript, unpaper, pdftk,
7 xvfb-run, liberation_ttf, file, tesseract }:
11 perlPackages.buildPerlPackage rec {
16 url = "mirror://sourceforge/gscan2pdf/gscan2pdf-${version}.tar.xz";
17 hash = "sha256-NGz6DUa7TdChpgwmD9pcGdvYr3R+Ft3jPPSJpybCW4Q=";
21 # fixes warnings during tests. See https://sourceforge.net/p/gscan2pdf/bugs/421
23 name = "0001-Remove-given-and-when-keywords-and-operator.patch";
24 url = "https://sourceforge.net/p/gscan2pdf/bugs/_discuss/thread/602a7cedfd/1ea4/attachment/0001-Remove-given-and-when-keywords-and-operator.patch";
25 hash = "sha256-JtrHUkfEKnDhWfEVdIdYVlr5b/xChTzsrrPmruLaJ5M=";
27 # fixes an error with utf8 file names. See https://sourceforge.net/p/gscan2pdf/bugs/400
28 ./image-utf8-fix.patch
31 nativeBuildInputs = [ wrapGAppsHook ];
34 [ librsvg sane-backends sane-frontends ] ++
42 GlibObjectIntrospection
67 fontSubstitute = "${liberation_ttf}/share/fonts/truetype/LiberationSans-Regular.ttf";
69 # Required for the program to properly load its SVG assets
70 substituteInPlace bin/gscan2pdf \
71 --replace "/usr/share" "$out/share"
73 # Substitute the non-free Helvetica font in the tests
74 sed -i 's|-pointsize|-font ${fontSubstitute} -pointsize|g' t/*.t
79 find $out -type f -name "*.pod" -delete
81 # Add runtime dependencies
82 wrapProgram "$out/bin/gscan2pdf" \
83 --prefix PATH : "${sane-backends}/bin" \
84 --prefix PATH : "${imagemagick}/bin" \
85 --prefix PATH : "${libtiff}/bin" \
86 --prefix PATH : "${djvulibre}/bin" \
87 --prefix PATH : "${poppler_utils}/bin" \
88 --prefix PATH : "${ghostscript}/bin" \
89 --prefix PATH : "${unpaper}/bin" \
90 --prefix PATH : "${pdftk}/bin"
93 enableParallelBuilding = true;
95 installTargets = [ "install" ];
97 outputs = [ "out" "man" ];
110 tesseract # tests are expecting tesseract 3.x precisely
111 ] ++ (with perlPackages; [
116 # Temporarily disable a test failing after a patch imagemagick update.
117 # It might only due to the reporting and matching used in the test.
118 # See https://github.com/NixOS/nixpkgs/issues/223446
119 # See https://sourceforge.net/p/gscan2pdf/bugs/417/
121 # Failed test 'valid TIFF created'
122 # at t/131_save_tiff.t line 44.
123 # 'test.tif TIFF 70x46 70x46+0+0 8-bit sRGB 10024B 0.000u 0:00.000
125 # doesn't match '(?^:test.tif TIFF 70x46 70x46\+0\+0 8-bit sRGB [7|9][.\d]+K?B)'
128 # Temporarily disable a dubiously failing test:
129 # t/169_import_scan.t ........................... 1/1
130 # # Failed test 'variable-height scan imported with expected size'
131 # # at t/169_import_scan.t line 50.
134 # # Looks like you failed 1 test of 1.
135 # t/169_import_scan.t ........................... Dubious, test returned 1 (wstat 256, 0x100)
136 rm t/169_import_scan.t
138 # Disable a test which passes but reports an incorrect status
139 # t/0601_Dialog_Scan.t .......................... All 14 subtests passed
140 # t/0601_Dialog_Scan.t (Wstat: 139 Tests: 14 Failed: 0)
141 # Non-zero wait status: 139
142 rm t/0601_Dialog_Scan.t
144 xvfb-run -s '-screen 0 800x600x24' \
149 description = "A GUI to produce PDFs or DjVus from scanned documents";
150 homepage = "https://gscan2pdf.sourceforge.net/";
151 license = licenses.gpl3;
152 maintainers = with maintainers; [ pacien ];
153 mainProgram = "gscan2pdf";