Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv
2, fetchurl
3, fetchpatch
4, makeWrapper
5, symlinkJoin
6, pkg-config
7, libtool
8, gtk2
9, libxml2
10, libxslt
11, libusb-compat-0_1
12, sane-backends
13, rpm
14, cpio
15, getopt
16, autoPatchelfHook
17, gcc
18}:
19let common_meta = {
20 homepage = "http://download.ebz.epson.net/dsc/search/01/search/?OSC=LX";
21 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
22 license = with lib.licenses; epson;
23 platforms = with lib.platforms; linux;
24};
25in
26############################
27#
28# PLUGINS
29#
30############################
31
32# adding a plugin for another printer shouldn't be too difficult, but you need the firmware to test...
33let plugins = {
34 v330 = stdenv.mkDerivation rec {
35 name = "iscan-v330-bundle";
36 version = "2.30.4";
37
38 src = fetchurl {
39 # To find new versions, visit
40 # http://download.ebz.epson.net/dsc/search/01/search/?OSC=LX and search for
41 # some printer like for instance "WF-7210" to get to the most recent
42 # version.
43 # NOTE: Don't forget to update the webarchive link too!
44 urls = [
45 "https://download2.ebz.epson.net/iscan/plugin/perfection-v330/rpm/x64/iscan-perfection-v330-bundle-${version}.x64.rpm.tar.gz"
46 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/perfection-v330/rpm/x64/iscan-perfection-v330-bundle-${version}.x64.rpm.tar.gz"
47 ];
48 sha256 = "056c04pfsf98nnknphg28l489isqb6y4l2c8g7wqhclwgj7m338i";
49 };
50
51 nativeBuildInputs = [ autoPatchelfHook rpm ];
52
53 installPhase = ''
54 ${rpm}/bin/rpm2cpio plugins/esci-interpreter-perfection-v330-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
55 mkdir $out{,/share,/lib}
56 cp -r ./usr/share/{iscan-data,esci}/ $out/share/
57 cp -r ./usr/lib64/esci $out/lib
58 '';
59
60 passthru = {
61 registrationCommand = ''
62 $registry --add interpreter usb 0x04b8 0x0142 "$plugin/lib/esci/libesci-interpreter-perfection-v330 $plugin/share/esci/esfwad.bin"
63 '';
64 hw = "Perfection V330 Photo";
65 };
66 meta = common_meta // { description = "Plugin to support " + passthru.hw + " scanner in sane"; };
67 };
68 v370 = stdenv.mkDerivation rec {
69 name = "iscan-v370-bundle";
70 version = "2.30.4";
71
72 src = fetchurl {
73 urls = [
74 "https://download2.ebz.epson.net/iscan/plugin/perfection-v370/rpm/x64/iscan-perfection-v370-bundle-${version}.x64.rpm.tar.gz"
75 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/perfection-v370/rpm/x64/iscan-perfection-v370-bundle-${version}.x64.rpm.tar.gz"
76 ];
77 sha256 = "1ff7adp9mha1i2ibllz540xkagpy8r757h4s3h60bgxbyzv2yggr";
78 };
79
80 nativeBuildInputs = [ autoPatchelfHook rpm ];
81
82 installPhase = ''
83 cd plugins
84 ${rpm}/bin/rpm2cpio iscan-plugin-perfection-v370-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
85
86
87 mkdir -p $out/share $out/lib
88 cp -r usr/share/{iscan-data,iscan}/ $out/share
89 cp -r usr/lib64/iscan $out/lib
90 mv $out/share/iscan $out/share/esci
91 mv $out/lib/iscan $out/lib/esci
92 '';
93
94 passthru = {
95 registrationCommand = ''
96 $registry --add interpreter usb 0x04b8 0x014a "$plugin/lib/esci/libiscan-plugin-perfection-v370 $plugin/share/esci/esfwdd.bin"
97 '';
98 hw = "Perfection V37/V370";
99 };
100 meta = common_meta // { description = "Plugin to support " + passthru.hw + " scanner in sane"; };
101 };
102 v600 = stdenv.mkDerivation rec {
103 pname = "iscan-gt-x820-bundle";
104 version = "2.30.4";
105
106 nativeBuildInputs = [ autoPatchelfHook rpm ];
107 src = fetchurl {
108 urls = [
109 "https://download2.ebz.epson.net/iscan/plugin/gt-x820/rpm/x64/iscan-gt-x820-bundle-${version}.x64.rpm.tar.gz"
110 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/gt-x820/rpm/x64/iscan-gt-x820-bundle-${version}.x64.rpm.tar.gz"
111 ];
112 sha256 = "1vlba7dsgpk35nn3n7is8nwds3yzlk38q43mppjzwsz2d2n7sr33";
113 };
114 installPhase = ''
115 cd plugins
116 ${rpm}/bin/rpm2cpio iscan-plugin-gt-x820-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
117 mkdir $out
118 cp -r usr/share $out
119 cp -r usr/lib64 $out/lib
120 mv $out/share/iscan $out/share/esci
121 mv $out/lib/iscan $out/lib/esci
122 '';
123 passthru = {
124 registrationCommand = ''
125 $registry --add interpreter usb 0x04b8 0x013a "$plugin/lib/esci/libesintA1 $plugin/share/esci/esfwA1.bin"
126 '';
127 hw = "Perfection V600 Photo";
128 };
129 meta = common_meta // { description = "iscan esci x820 plugin for " + passthru.hw; };
130 };
131 x770 = stdenv.mkDerivation rec {
132 pname = "iscan-gt-x770-bundle";
133 version = "2.30.4";
134
135 nativeBuildInputs = [ autoPatchelfHook rpm ];
136 src = fetchurl {
137 urls = [
138 "https://download2.ebz.epson.net/iscan/plugin/gt-x770/rpm/x64/iscan-gt-x770-bundle-${version}.x64.rpm.tar.gz"
139 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/gt-x770/rpm/x64/iscan-gt-x770-bundle-${version}.x64.rpm.tar.gz"
140 ];
141 sha256 = "1chxdm6smv2d14pn2jl9xyd0vr42diy7vpskd3b9a61gf5h3gj03";
142 };
143 installPhase = ''
144 cd plugins
145 ${rpm}/bin/rpm2cpio iscan-plugin-gt-x770-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
146 mkdir $out
147 cp -r usr/share $out
148 cp -r usr/lib64 $out/lib
149 mv $out/share/iscan $out/share/esci
150 mv $out/lib/iscan $out/lib/esci
151 '';
152 passthru = {
153 registrationCommand = ''
154 $registry --add interpreter usb 0x04b8 0x0130 "$plugin/lib/esci/libesint7C $plugin/share/esci/esfw7C.bin"
155 '';
156 hw = "Perfection V500 Photo";
157 };
158 meta = common_meta // { description = "iscan esci x770 plugin for " + passthru.hw; };
159 };
160 f720 = stdenv.mkDerivation rec {
161 pname = "iscan-gt-f720-bundle";
162 version = "2.30.4";
163
164 nativeBuildInputs = [ autoPatchelfHook ];
165 buildInputs = [ gcc.cc.lib ];
166 src = fetchurl {
167 urls = [
168 "https://download2.ebz.epson.net/iscan/plugin/gt-f720/rpm/x64/iscan-gt-f720-bundle-${version}.x64.rpm.tar.gz"
169 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/gt-f720/rpm/x64/iscan-gt-f720-bundle-${version}.x64.rpm.tar.gz"
170 ];
171 sha256 = "1xnbmb2rn610kqpg1x6k1cc13zlmx2f3l2xnj6809rnhg96qqn20";
172 };
173 installPhase = ''
174 cd plugins
175 ${rpm}/bin/rpm2cpio esci-interpreter-gt-f720-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
176 mkdir $out
177 cp -r usr/share $out
178 cp -r usr/lib64 $out/lib
179 '';
180
181 passthru = {
182 registrationCommand = ''
183 $registry --add interpreter usb 0x04b8 0x0131 "$plugin/lib/esci/libesci-interpreter-gt-f720 $plugin/share/esci/esfw8b.bin"
184 '';
185 hw = "GT-F720, GT-S620, Perfection V30, Perfection V300 Photo";
186 };
187
188 meta = common_meta // { description = "iscan esci f720 plugin for " + passthru.hw; };
189 };
190 s80 = stdenv.mkDerivation rec {
191 pname = "iscan-gt-s80-bundle";
192 version = "2.30.4";
193
194 nativeBuildInputs = [ autoPatchelfHook ];
195 buildInputs = [ gcc.cc.lib libtool ];
196 src = fetchurl {
197 urls = [
198 "https://download2.ebz.epson.net/iscan/plugin/gt-s80/rpm/x64/iscan-gt-s80-bundle-${version}.x64.rpm.tar.gz"
199 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/gt-s80/rpm/x64/iscan-gt-s80-bundle-${version}.x64.rpm.tar.gz"
200 ];
201 sha256 = "00qfdgs03k7bbs67zjrk8hbxvlyinsmk890amp9cmpfjfzdxgg58";
202 };
203 installPhase = ''
204 cd plugins
205 ${rpm}/bin/rpm2cpio esci-interpreter-gt-s80-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
206 ${rpm}/bin/rpm2cpio iscan-plugin-esdip-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
207 mkdir $out
208 cp -r usr/share $out
209 cp -r usr/lib64 $out/lib
210 mkdir $out/share/esci
211 '';
212
213 passthru = {
214 registrationCommand = ''
215 $registry --add interpreter usb 0x04b8 0x0136 "$plugin/lib/esci/libesci-interpreter-gt-s80.so"
216 $registry --add interpreter usb 0x04b8 0x0137 "$plugin/lib/esci/libesci-interpreter-gt-s50.so"
217 $registry --add interpreter usb 0x04b8 0x0143 "$plugin/lib/esci/libesci-interpreter-gt-s50.so"
218 $registry --add interpreter usb 0x04b8 0x0144 "$plugin/lib/esci/libesci-interpreter-gt-s80.so"
219 '';
220 hw = "ES-D200, ED-D350, ES-D400, GT-S50, GT-S55, GT-S80, GT-S85";
221 };
222
223 meta = common_meta // { description = "iscan esci s80 plugin for " + passthru.hw; };
224 };
225 s650 = stdenv.mkDerivation rec {
226 name = "iscan-gt-s650-bundle";
227 version = "2.30.4";
228
229 src = fetchurl {
230 urls = [
231 "https://download2.ebz.epson.net/iscan/plugin/gt-s650/rpm/x64/iscan-gt-s650-bundle-${version}.x64.rpm.tar.gz"
232 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/gt-s650/rpm/x64/iscan-gt-s650-bundle-${version}.x64.rpm.tar.gz"
233 ];
234 sha256 = "0fn4lz4g0a8l301v6yv7fwl37wgwhz5y90nf681f655xxc91hqh7";
235 };
236
237 nativeBuildInputs = [ autoPatchelfHook rpm ];
238
239 installPhase = ''
240 cd plugins
241 ${rpm}/bin/rpm2cpio iscan-plugin-gt-s650-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
242 mkdir $out
243 cp -r usr/share $out
244 cp -r usr/lib64 $out/lib
245 mv $out/share/iscan $out/share/esci
246 mv $out/lib/iscan $out/lib/esci
247 '';
248
249 passthru = {
250 registrationCommand = ''
251 $registry --add interpreter usb 0x04b8 0x013c "$plugin/lib/esci/libiscan-plugin-gt-s650 $plugin/share/esci/esfw010c.bin"
252 $registry --add interpreter usb 0x04b8 0x013d "$plugin/lib/esci/libiscan-plugin-gt-s650 $plugin/share/esci/esfw010c.bin"
253 '';
254 hw = "GT-S650, Perfection V19, Perfection V39";
255 };
256 meta = common_meta // { description = "iscan GT-S650 for " + passthru.hw; };
257 };
258 x750 = stdenv.mkDerivation rec {
259 name = "iscan-gt-x750-bundle";
260 version = "2.30.4";
261
262 src = fetchurl {
263 urls = [
264 "https://download2.ebz.epson.net/iscan/plugin/gt-x750/rpm/x64/iscan-gt-x750-bundle-${version}.x64.rpm.tar.gz"
265 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/gt-x750/rpm/x64/iscan-gt-x750-bundle-${version}.x64.rpm.tar.gz"
266 ];
267 sha256 = "sha256-9EeBHmh1nwSxnTnevPP8RZ4WBdyY+itR3VXo2I7f5N0=";
268 };
269
270 nativeBuildInputs = [ autoPatchelfHook rpm ];
271
272 installPhase = ''
273 cd plugins
274 ${rpm}/bin/rpm2cpio iscan-plugin-gt-x750-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
275 mkdir $out
276 cp -r usr/share $out
277 cp -r usr/lib64 $out/lib
278 mv $out/share/iscan $out/share/esci
279 mv $out/lib/iscan $out/lib/esci
280 '';
281
282 passthru = {
283 registrationCommand = ''
284 $registry --add interpreter usb 0x04b8 0x0119 "$plugin/lib/esci/libesint54 $plugin/share/esci/esfw54.bin"
285 '';
286 hw = "GT-X750, Perfection 4490";
287 };
288 meta = common_meta // { description = "iscan GT-X750 for " + passthru.hw; };
289 };
290 network = stdenv.mkDerivation rec {
291 pname = "iscan-nt-bundle";
292 # for the version, look for the driver of XP-750 in the search page
293 version = "2.30.4";
294
295 buildInputs = [ stdenv.cc.cc.lib ];
296 nativeBuildInputs = [ autoPatchelfHook ];
297
298 src = fetchurl {
299 urls = [
300 "https://download2.ebz.epson.net/iscan/general/rpm/x64/iscan-bundle-${version}.x64.rpm.tar.gz"
301 "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/general/rpm/x64/iscan-bundle-${version}.x64.rpm.tar.gz"
302 ];
303 sha256 = "0jssigsgkxb9i7qa7db291a1gbvwl795i4ahvb7bnqp33czkj85k";
304 };
305 installPhase = ''
306 cd plugins
307 ${rpm}/bin/rpm2cpio iscan-network-nt-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
308
309 mkdir $out
310 cp -r usr/share $out
311 cp -r usr/lib64 $out/lib
312 mkdir $out/share/esci
313 '';
314 passthru = {
315 registrationCommand = "";
316 hw = "network";
317 };
318
319 meta = common_meta // { description = "iscan network plugin"; };
320 };
321};
322in
323let fwdir = symlinkJoin {
324 name = "esci-firmware-dir";
325 paths = lib.mapAttrsToList (name: value: value + /share/esci) plugins;
326};
327in
328let iscan-data = stdenv.mkDerivation rec {
329 pname = "iscan-data";
330 version = "1.39.2-1";
331
332 src = fetchurl {
333 urls = [
334 "http://support.epson.net/linux/src/scanner/iscan/iscan-data_${version}.tar.gz"
335 "https://web.archive.org/web/http://support.epson.net/linux/src/scanner/iscan/iscan-data_${version}.tar.gz"
336 ];
337 sha256 = "092qhlnjjgz11ifx6mng7mz20i44gc0nlccrbmw18xr5hipbqqka";
338 };
339
340 buildInputs = [
341 libxslt
342 ];
343
344 meta = common_meta;
345};
346in
347stdenv.mkDerivation rec {
348 pname = "iscan";
349 version = "2.30.4-2";
350
351 src = fetchurl {
352 urls = [
353 "http://support.epson.net/linux/src/scanner/iscan/iscan_${version}.tar.gz"
354 "https://web.archive.org/web/http://support.epson.net/linux/src/scanner/iscan/iscan_${version}.tar.gz"
355 ];
356 sha256 = "1ma76jj0k3bz0fy06fiyl4di4y77rcryb0mwjmzs5ms2vq9rjysr";
357 };
358
359 nativeBuildInputs = [ pkg-config libtool makeWrapper ];
360 buildInputs = [
361 gtk2
362 libxml2
363 libusb-compat-0_1
364 sane-backends
365 ];
366
367 patches = [
368 # Patch for compatibility with libpng versions greater than 10499
369 (fetchpatch {
370 urls = [
371 "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-gfx/iscan/files/iscan-2.28.1.3+libpng-1.5.patch?h=b6e4c805d53b49da79a0f64ef16bb82d6d800fcf"
372 "https://web.archive.org/web/https://gitweb.gentoo.org/repo/gentoo.git/plain/media-gfx/iscan/files/iscan-2.28.1.3+libpng-1.5.patch?h=b6e4c805d53b49da79a0f64ef16bb82d6d800fcf"
373 ];
374 sha256 = "04y70qjd220dpyh771fiq50lha16pms98mfigwjczdfmx6kpj1jd";
375 })
376 # Patch iscan to search appropriate folders for firmware files
377 ./firmware_location.patch
378 # Patch deprecated use of sscanf code to use a more modern C99 compatible version
379 ./sscanf.patch
380 ];
381 patchFlags = [ "-p0" ];
382
383 configureFlags = [ "--enable-dependency-reduction" "--disable-frontend" ];
384
385 postConfigure = ''
386 echo '#define NIX_ESCI_PREFIX "'${fwdir}'"' >> config.h
387 '';
388
389 postInstall = ''
390 mkdir -p $out/etc/sane.d
391 cp backend/epkowa.conf $out/etc/sane.d
392 echo "epkowa" > $out/etc/sane.d/dll.conf
393 ln -s ${iscan-data}/share/iscan-data $out/share/iscan-data
394 mkdir -p $out/lib/iscan
395 ln -s ${plugins.network}/lib/iscan/network $out/lib/iscan/network
396 '';
397 postFixup = ''
398 # iscan-registry is a shell script requiring getopt
399 wrapProgram $out/bin/iscan-registry --prefix PATH : ${getopt}/bin
400 registry=$out/bin/iscan-registry;
401 '' +
402 lib.concatStrings (lib.mapAttrsToList
403 (name: value: ''
404 plugin=${value};
405 ${value.passthru.registrationCommand}
406 '')
407 plugins);
408 meta = common_meta // {
409 description = "sane-epkowa backend for some epson scanners";
410 longDescription = ''
411 Includes gui-less iscan (aka. Image Scan! for Linux).
412 Supported hardware: at least :
413 '' +
414 lib.concatStringsSep ", " (lib.mapAttrsToList (name: value: value.passthru.hw) plugins);
415 maintainers = with lib.maintainers; [ symphorien dominikh ];
416 };
417}