nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 165 lines 3.9 kB view raw
1{ 2 lib, 3 fetchurl, 4 perlPackages, 5 wrapGAppsHook3, 6 # libs 7 librsvg, 8 sane-backends, 9 sane-frontends, 10 # runtime dependencies 11 imagemagick, 12 libtiff, 13 djvulibre, 14 poppler-utils, 15 ghostscript, 16 unpaper, 17 pdftk, 18 # test dependencies 19 xvfb-run, 20 liberation_ttf, 21 file, 22 tesseract3, 23}: 24 25perlPackages.buildPerlPackage rec { 26 pname = "gscan2pdf"; 27 version = "2.13.4"; 28 29 src = fetchurl { 30 url = "mirror://sourceforge/gscan2pdf/gscan2pdf-${version}.tar.xz"; 31 hash = "sha256-4HcTkVJBscBb8AxeN6orMQFVR0w4hFfkGhxQOzP3mWk="; 32 }; 33 34 patches = [ 35 # fixes an error with utf8 file names. See https://sourceforge.net/p/gscan2pdf/bugs/400 36 ./image-utf8-fix.patch 37 ]; 38 39 nativeBuildInputs = [ wrapGAppsHook3 ]; 40 41 buildInputs = [ 42 librsvg 43 sane-backends 44 sane-frontends 45 ] 46 ++ (with perlPackages; [ 47 Gtk3 48 Gtk3ImageView 49 Gtk3SimpleList 50 Cairo 51 CairoGObject 52 Glib 53 GlibObjectIntrospection 54 GooCanvas2 55 GraphicsTIFF 56 IPCSystemSimple 57 LocaleCodes 58 LocaleGettext 59 PDFBuilder 60 ImagePNGLibpng 61 ImageSane 62 SetIntSpan 63 ImageMagick 64 ConfigGeneral 65 ListMoreUtils 66 HTMLParser 67 ProcProcessTable 68 LogLog4perl 69 TryTiny 70 DataUUID 71 DateCalc 72 IOString 73 FilesysDf 74 SubOverride 75 ]); 76 77 postPatch = 78 let 79 fontSubstitute = "${liberation_ttf}/share/fonts/truetype/LiberationSans-Regular.ttf"; 80 in 81 '' 82 # Required for the program to properly load its SVG assets 83 substituteInPlace bin/gscan2pdf \ 84 --replace "/usr/share" "$out/share" 85 86 # Substitute the non-free Helvetica font in the tests 87 sed -i 's|-pointsize|-font ${fontSubstitute} -pointsize|g' t/*.t 88 ''; 89 90 postInstall = '' 91 # Remove impurity 92 find $out -type f -name "*.pod" -delete 93 94 # Add runtime dependencies 95 wrapProgram "$out/bin/gscan2pdf" \ 96 --prefix PATH : "${sane-backends}/bin" \ 97 --prefix PATH : "${imagemagick}/bin" \ 98 --prefix PATH : "${libtiff}/bin" \ 99 --prefix PATH : "${djvulibre}/bin" \ 100 --prefix PATH : "${poppler-utils}/bin" \ 101 --prefix PATH : "${ghostscript}/bin" \ 102 --prefix PATH : "${unpaper}/bin" \ 103 --prefix PATH : "${pdftk}/bin" 104 ''; 105 106 enableParallelBuilding = true; 107 108 installTargets = [ "install" ]; 109 110 outputs = [ 111 "out" 112 "man" 113 ]; 114 115 nativeCheckInputs = [ 116 imagemagick 117 libtiff 118 djvulibre 119 poppler-utils 120 ghostscript 121 unpaper 122 pdftk 123 124 xvfb-run 125 file 126 tesseract3 # tests are expecting tesseract 3.x precisely 127 ] 128 ++ (with perlPackages; [ 129 TestPod 130 ]); 131 132 checkPhase = '' 133 # Temporarily disable a dubiously failing test: 134 # t/169_import_scan.t ........................... 1/1 135 # # Failed test 'variable-height scan imported with expected size' 136 # # at t/169_import_scan.t line 50. 137 # # got: '179' 138 # # expected: '296' 139 # # Looks like you failed 1 test of 1. 140 # t/169_import_scan.t ........................... Dubious, test returned 1 (wstat 256, 0x100) 141 rm t/169_import_scan.t 142 143 # Disable a test failing because of a warning interfering with the pinned output 144 # t/3722_user_defined.t ......................... 1/2 145 # Failed test 'user_defined caught error injected in queue' 146 # at t/3722_user_defined.t line 41. 147 # got: 'error 148 # WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert"' 149 # expected: 'error' 150 # Looks like you failed 1 test of 2. 151 rm t/3722_user_defined.t 152 153 export XDG_CACHE_HOME="$(mktemp -d)" 154 xvfb-run -s '-screen 0 800x600x24' \ 155 make test 156 ''; 157 158 meta = with lib; { 159 description = "GUI to produce PDFs or DjVus from scanned documents"; 160 homepage = "https://gscan2pdf.sourceforge.net/"; 161 license = licenses.gpl3; 162 maintainers = with maintainers; [ euxane ]; 163 mainProgram = "gscan2pdf"; 164 }; 165}