anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / misc / drivers / epkowa / default.nix
blobbb0e1eb7b6fd5719f3d4cf891faf34aac68bd4b9
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
19 let 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;
26 ############################
28 #  PLUGINS
30 ############################
32 # adding a plugin for another printer shouldn't be too difficult, but you need the firmware to test...
33 let plugins = {
34   v330 = stdenv.mkDerivation rec {
35     name = "iscan-v330-bundle";
36     version = "2.30.4";
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     };
51     nativeBuildInputs = [ autoPatchelfHook rpm ];
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     '';
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";
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     };
80     nativeBuildInputs = [ autoPatchelfHook rpm ];
82     installPhase = ''
83       cd plugins
84       ${rpm}/bin/rpm2cpio iscan-plugin-perfection-v370-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
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     '';
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   v550 = stdenv.mkDerivation rec {
103     pname = "iscan-perfection-v550-bundle";
104     version = "2.30.4";
106     nativeBuildInputs = [ autoPatchelfHook rpm ];
107     src = fetchurl {
108       urls = [
109         "https://download2.ebz.epson.net/iscan/plugin/perfection-v550/rpm/x64/iscan-perfection-v550-bundle-${version}.x64.rpm.tar.gz"
110         "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/perfection-v550/rpm/x64/iscan-perfection-v550-bundle-${version}.x64.rpm.tar.gz"
111       ];
112       sha256 = "f8b3abf21354fc5b9bc87753cef950b6c0f07bf322a94aaff2c163bafcf50cd9";
113     };
114     installPhase = ''
115       cd plugins
116       ${rpm}/bin/rpm2cpio iscan-plugin-perfection-v550-*.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 0x013b "$plugin/lib/esci/libiscan-plugin-perfection-v550 $plugin/share/esci/esfweb.bin"
126       '';
127       hw = "Perfection V550 Photo";
128     };
129     meta = common_meta // { description = "Plugin to support " + passthru.hw + " scanner in sane"; };
130   };
131   v600 = stdenv.mkDerivation rec {
132     pname = "iscan-gt-x820-bundle";
133     version = "2.30.4";
135     nativeBuildInputs = [ autoPatchelfHook rpm ];
136     src = fetchurl {
137       urls = [
138         "https://download2.ebz.epson.net/iscan/plugin/gt-x820/rpm/x64/iscan-gt-x820-bundle-${version}.x64.rpm.tar.gz"
139         "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"
140       ];
141       sha256 = "1vlba7dsgpk35nn3n7is8nwds3yzlk38q43mppjzwsz2d2n7sr33";
142     };
143     installPhase = ''
144       cd plugins
145       ${rpm}/bin/rpm2cpio iscan-plugin-gt-x820-*.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 0x013a "$plugin/lib/esci/libesintA1 $plugin/share/esci/esfwA1.bin"
155       '';
156       hw = "Perfection V600 Photo";
157     };
158     meta = common_meta // { description = "iscan esci x820 plugin for " + passthru.hw; };
159   };
160   x770 = stdenv.mkDerivation rec {
161     pname = "iscan-gt-x770-bundle";
162     version = "2.30.4";
164     nativeBuildInputs = [ autoPatchelfHook rpm ];
165     src = fetchurl {
166       urls = [
167         "https://download2.ebz.epson.net/iscan/plugin/gt-x770/rpm/x64/iscan-gt-x770-bundle-${version}.x64.rpm.tar.gz"
168         "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"
169       ];
170       sha256 = "1chxdm6smv2d14pn2jl9xyd0vr42diy7vpskd3b9a61gf5h3gj03";
171     };
172     installPhase = ''
173       cd plugins
174       ${rpm}/bin/rpm2cpio iscan-plugin-gt-x770-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
175       mkdir $out
176       cp -r usr/share $out
177       cp -r usr/lib64 $out/lib
178       mv $out/share/iscan $out/share/esci
179       mv $out/lib/iscan $out/lib/esci
180     '';
181     passthru = {
182       registrationCommand = ''
183         $registry --add interpreter usb 0x04b8 0x0130 "$plugin/lib/esci/libesint7C $plugin/share/esci/esfw7C.bin"
184       '';
185       hw = "Perfection V500 Photo";
186     };
187     meta = common_meta // { description = "iscan esci x770 plugin for " + passthru.hw; };
188   };
189   f720 = stdenv.mkDerivation rec {
190     pname = "iscan-gt-f720-bundle";
191     version = "2.30.4";
193     nativeBuildInputs = [ autoPatchelfHook ];
194     buildInputs = [ gcc.cc.lib ];
195     src = fetchurl {
196       urls = [
197         "https://download2.ebz.epson.net/iscan/plugin/gt-f720/rpm/x64/iscan-gt-f720-bundle-${version}.x64.rpm.tar.gz"
198         "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"
199       ];
200       sha256 = "1xnbmb2rn610kqpg1x6k1cc13zlmx2f3l2xnj6809rnhg96qqn20";
201     };
202     installPhase = ''
203       cd plugins
204       ${rpm}/bin/rpm2cpio esci-interpreter-gt-f720-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
205       mkdir $out
206       cp -r usr/share $out
207       cp -r usr/lib64 $out/lib
208     '';
210     passthru = {
211       registrationCommand = ''
212         $registry --add interpreter usb 0x04b8 0x0131 "$plugin/lib/esci/libesci-interpreter-gt-f720 $plugin/share/esci/esfw8b.bin"
213       '';
214       hw = "GT-F720, GT-S620, Perfection V30, Perfection V300 Photo";
215     };
217     meta = common_meta // { description = "iscan esci f720 plugin for " + passthru.hw; };
218   };
219   s80 = stdenv.mkDerivation rec {
220     pname = "iscan-gt-s80-bundle";
221     version = "2.30.4";
223     nativeBuildInputs = [ autoPatchelfHook ];
224     buildInputs = [ gcc.cc.lib libtool ];
225     src = fetchurl {
226       urls = [
227         "https://download2.ebz.epson.net/iscan/plugin/gt-s80/rpm/x64/iscan-gt-s80-bundle-${version}.x64.rpm.tar.gz"
228         "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"
229       ];
230       sha256 = "00qfdgs03k7bbs67zjrk8hbxvlyinsmk890amp9cmpfjfzdxgg58";
231     };
232     installPhase = ''
233       cd plugins
234       ${rpm}/bin/rpm2cpio esci-interpreter-gt-s80-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
235       ${rpm}/bin/rpm2cpio iscan-plugin-esdip-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
236       mkdir $out
237       cp -r usr/share $out
238       cp -r usr/lib64 $out/lib
239       mkdir $out/share/esci
240     '';
242     passthru = {
243       registrationCommand = ''
244         $registry --add interpreter usb 0x04b8 0x0136 "$plugin/lib/esci/libesci-interpreter-gt-s80.so"
245         $registry --add interpreter usb 0x04b8 0x0137 "$plugin/lib/esci/libesci-interpreter-gt-s50.so"
246         $registry --add interpreter usb 0x04b8 0x0143 "$plugin/lib/esci/libesci-interpreter-gt-s50.so"
247         $registry --add interpreter usb 0x04b8 0x0144 "$plugin/lib/esci/libesci-interpreter-gt-s80.so"
248       '';
249       hw = "ES-D200, ED-D350, ES-D400, GT-S50, GT-S55, GT-S80, GT-S85";
250     };
252     meta = common_meta // { description = "iscan esci s80 plugin for " + passthru.hw; };
253   };
254   s600 = stdenv.mkDerivation rec {
255     name = "iscan-gt-s600-bundle";
256     version = "2.30.4";
258     src = fetchurl {
259       urls = [
260         "https://download2.ebz.epson.net/iscan/plugin/gt-s600/rpm/x64/iscan-gt-s600-bundle-${version}.x64.rpm.tar.gz"
261         "https://web.archive.org/web/20240614120113/https://download2.ebz.epson.net/iscan/plugin/gt-s600/rpm/x64/iscan-gt-s600-bundle-${version}.x64.rpm.tar.gz"
262       ];
263       sha256 = "fe1356b1d5c40bc5ac985a5693166efb9e5049a78b412f49c385eb503eadf2c6";
264     };
266     nativeBuildInputs = [ autoPatchelfHook rpm ];
268     installPhase = ''
269       cd plugins
270       ${rpm}/bin/rpm2cpio iscan-plugin-gt-s600-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
271       mkdir $out
272       cp -r usr/share $out
273       cp -r usr/lib64 $out/lib
274       mv $out/share/iscan $out/share/esci
275       mv $out/lib/iscan $out/lib/esci
276     '';
278     passthru = {
279       registrationCommand = ''
280         $registry --add interpreter usb 0x04b8 0x012d "$plugin/lib/esci/libesint66 $plugin/share/esci/esfw66.bin"
281       '';
282       hw = "GT-F650, GT-S600, Perfection V10, Perfection V100 Photo";
283     };
284     meta = common_meta // { description = "iscan gt-s600 plugin for " + passthru.hw; };
285   };
286   s650 = stdenv.mkDerivation rec {
287     name = "iscan-gt-s650-bundle";
288     version = "2.30.4";
290     src = fetchurl {
291       urls = [
292         "https://download2.ebz.epson.net/iscan/plugin/gt-s650/rpm/x64/iscan-gt-s650-bundle-${version}.x64.rpm.tar.gz"
293         "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"
294       ];
295       sha256 = "0fn4lz4g0a8l301v6yv7fwl37wgwhz5y90nf681f655xxc91hqh7";
296     };
298     nativeBuildInputs = [ autoPatchelfHook rpm ];
300     installPhase = ''
301       cd plugins
302       ${rpm}/bin/rpm2cpio iscan-plugin-gt-s650-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
303       mkdir $out
304       cp -r usr/share $out
305       cp -r usr/lib64 $out/lib
306       mv $out/share/iscan $out/share/esci
307       mv $out/lib/iscan $out/lib/esci
308     '';
310     passthru = {
311       registrationCommand = ''
312         $registry --add interpreter usb 0x04b8 0x013c "$plugin/lib/esci/libiscan-plugin-gt-s650 $plugin/share/esci/esfw010c.bin"
313         $registry --add interpreter usb 0x04b8 0x013d "$plugin/lib/esci/libiscan-plugin-gt-s650 $plugin/share/esci/esfw010c.bin"
314       '';
315       hw = "GT-S650, Perfection V19, Perfection V39";
316     };
317     meta = common_meta // { description = "iscan GT-S650 for " + passthru.hw; };
318   };
319   x750 = stdenv.mkDerivation rec {
320     name = "iscan-gt-x750-bundle";
321     version = "2.30.4";
323     src = fetchurl {
324       urls = [
325         "https://download2.ebz.epson.net/iscan/plugin/gt-x750/rpm/x64/iscan-gt-x750-bundle-${version}.x64.rpm.tar.gz"
326         "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"
327       ];
328       sha256 = "sha256-9EeBHmh1nwSxnTnevPP8RZ4WBdyY+itR3VXo2I7f5N0=";
329     };
331     nativeBuildInputs = [ autoPatchelfHook rpm ];
333     installPhase = ''
334       cd plugins
335       ${rpm}/bin/rpm2cpio iscan-plugin-gt-x750-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
336       mkdir $out
337       cp -r usr/share $out
338       cp -r usr/lib64 $out/lib
339       mv $out/share/iscan $out/share/esci
340       mv $out/lib/iscan $out/lib/esci
341     '';
343     passthru = {
344       registrationCommand = ''
345         $registry --add interpreter usb 0x04b8 0x0119 "$plugin/lib/esci/libesint54 $plugin/share/esci/esfw54.bin"
346       '';
347       hw = "GT-X750, Perfection 4490";
348     };
349     meta = common_meta // { description = "iscan GT-X750 for " + passthru.hw; };
350   };
351   gt1500 = stdenv.mkDerivation rec {
352     name = "iscan-gt-1500-bundle";
353     version = "2.30.4";
355     src = fetchurl {
356       urls = [
357         "https://download2.ebz.epson.net/iscan/plugin/gt-1500/rpm/x64/iscan-gt-1500-bundle-${version}.x64.rpm.tar.gz"
358         "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/plugin/gt-1500/rpm/x64/iscan-gt-1500-bundle-${version}.x64.rpm.tar.gz"
359       ];
360       sha256 = "sha256-1rVsbBsb+QtCOT1FsyhgvCbZIN6IeQH7rZXNmsD7cl8=";
361     };
363     nativeBuildInputs = [ autoPatchelfHook rpm ];
365     installPhase = ''
366       cd plugins
367       ${rpm}/bin/rpm2cpio iscan-plugin-gt-1500-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
368       mkdir $out
369       cp -r usr/share $out
370       cp -r usr/lib64 $out/lib
371       mv $out/share/iscan $out/share/esci
372       mv $out/lib/iscan $out/lib/esci
373     '';
375     passthru = {
376       registrationCommand = ''
377         $registry --add interpreter usb 0x04b8 0x0133 "$plugin/lib/esci/libesint86 $plugin/share/esci/esfw86.bin"
378       '';
379       hw = "GT-1500";
380     };
381     meta = common_meta // { description = "iscan GT-1500 for " + passthru.hw; };
382   };
383   network = stdenv.mkDerivation rec {
384     pname = "iscan-nt-bundle";
385     # for the version, look for the driver of XP-750 in the search page
386     version = "2.30.4";
388     buildInputs = [ (lib.getLib stdenv.cc.cc) ];
389     nativeBuildInputs = [ autoPatchelfHook ];
391     src = fetchurl {
392       urls = [
393         "https://download2.ebz.epson.net/iscan/general/rpm/x64/iscan-bundle-${version}.x64.rpm.tar.gz"
394         "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/general/rpm/x64/iscan-bundle-${version}.x64.rpm.tar.gz"
395       ];
396       sha256 = "0jssigsgkxb9i7qa7db291a1gbvwl795i4ahvb7bnqp33czkj85k";
397     };
398     installPhase = ''
399       cd plugins
400       ${rpm}/bin/rpm2cpio iscan-network-nt-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
402       mkdir $out
403       cp -r usr/share $out
404       cp -r usr/lib64 $out/lib
405       mkdir $out/share/esci
406     '';
407     passthru = {
408       registrationCommand = "";
409       hw = "network";
410     };
412     meta = common_meta // { description = "iscan network plugin"; };
413   };
416 let fwdir = symlinkJoin {
417   name = "esci-firmware-dir";
418   paths = lib.mapAttrsToList (name: value: value + /share/esci) plugins;
421 let iscan-data = stdenv.mkDerivation rec {
422   pname = "iscan-data";
423   version = "1.39.2-1";
425   src = fetchurl {
426     urls = [
427       "http://support.epson.net/linux/src/scanner/iscan/iscan-data_${version}.tar.gz"
428       "https://web.archive.org/web/http://support.epson.net/linux/src/scanner/iscan/iscan-data_${version}.tar.gz"
429     ];
430     sha256 = "092qhlnjjgz11ifx6mng7mz20i44gc0nlccrbmw18xr5hipbqqka";
431   };
433   buildInputs = [
434     libxslt
435   ];
437   meta = common_meta;
440 stdenv.mkDerivation rec {
441   pname = "iscan";
442   version = "2.30.4-2";
444   src = fetchurl {
445     urls = [
446       "http://support.epson.net/linux/src/scanner/iscan/iscan_${version}.tar.gz"
447       "https://web.archive.org/web/http://support.epson.net/linux/src/scanner/iscan/iscan_${version}.tar.gz"
448     ];
449     sha256 = "1ma76jj0k3bz0fy06fiyl4di4y77rcryb0mwjmzs5ms2vq9rjysr";
450   };
452   nativeBuildInputs = [ pkg-config libtool makeWrapper ];
453   buildInputs = [
454     gtk2
455     libxml2
456     libusb-compat-0_1
457     sane-backends
458   ];
460   patches = [
461     # Patch for compatibility with libpng versions greater than 10499
462     (fetchpatch {
463       urls = [
464         "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-gfx/iscan/files/iscan-2.28.1.3+libpng-1.5.patch?h=b6e4c805d53b49da79a0f64ef16bb82d6d800fcf"
465         "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"
466       ];
467       sha256 = "04y70qjd220dpyh771fiq50lha16pms98mfigwjczdfmx6kpj1jd";
468     })
469     # Patch iscan to search appropriate folders for firmware files
470     ./firmware_location.patch
471     # Patch deprecated use of sscanf code to use a more modern C99 compatible version
472     ./sscanf.patch
473   ];
474   patchFlags = [ "-p0" ];
476   configureFlags = [ "--enable-dependency-reduction" "--disable-frontend" ];
478   postConfigure = ''
479     echo '#define NIX_ESCI_PREFIX "'${fwdir}'"' >> config.h
480   '';
482   postInstall = ''
483     mkdir -p $out/etc/sane.d
484     cp backend/epkowa.conf $out/etc/sane.d
485     echo "epkowa" > $out/etc/sane.d/dll.conf
486     ln -s ${iscan-data}/share/iscan-data $out/share/iscan-data
487     mkdir -p $out/lib/iscan
488     ln -s ${plugins.network}/lib/iscan/network $out/lib/iscan/network
489   '';
490   postFixup = ''
491     # iscan-registry is a shell script requiring getopt
492     wrapProgram $out/bin/iscan-registry --prefix PATH : ${getopt}/bin
493     registry=$out/bin/iscan-registry;
494   '' +
495   lib.concatStrings (lib.mapAttrsToList
496     (name: value: ''
497       plugin=${value};
498       ${value.passthru.registrationCommand}
499     '')
500     plugins);
501   meta = common_meta // {
502     description = "sane-epkowa backend for some epson scanners";
503     longDescription = ''
504       Includes gui-less iscan (aka. Image Scan! for Linux).
505       Supported hardware: at least :
506     '' +
507     lib.concatStringsSep ", " (lib.mapAttrsToList (name: value: value.passthru.hw) plugins);
508     maintainers = with lib.maintainers; [ symphorien dominikh ];
509   };