python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / misc / drivers / epkowa / default.nix
blob37e4d2baa35ee36a147fa938b4839eb4e034765f
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   v600 = stdenv.mkDerivation rec {
103     pname = "iscan-gt-x820-bundle";
104     version = "2.30.4";
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";
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";
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     '';
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     };
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";
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     '';
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     };
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";
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     };
237     nativeBuildInputs = [ autoPatchelfHook rpm ];
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     '';
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   network = stdenv.mkDerivation rec {
259     pname = "iscan-nt-bundle";
260     # for the version, look for the driver of XP-750 in the search page
261     version = "2.30.4";
263     buildInputs = [ stdenv.cc.cc.lib ];
264     nativeBuildInputs = [ autoPatchelfHook ];
266     src = fetchurl {
267       urls = [
268         "https://download2.ebz.epson.net/iscan/general/rpm/x64/iscan-bundle-${version}.x64.rpm.tar.gz"
269         "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/general/rpm/x64/iscan-bundle-${version}.x64.rpm.tar.gz"
270       ];
271       sha256 = "0jssigsgkxb9i7qa7db291a1gbvwl795i4ahvb7bnqp33czkj85k";
272     };
273     installPhase = ''
274       cd plugins
275       ${rpm}/bin/rpm2cpio iscan-network-nt-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
277       mkdir $out
278       cp -r usr/share $out
279       cp -r usr/lib64 $out/lib
280       mkdir $out/share/esci
281     '';
282     passthru = {
283       registrationCommand = "";
284       hw = "network";
285     };
287     meta = common_meta // { description = "iscan network plugin"; };
288   };
291 let fwdir = symlinkJoin {
292   name = "esci-firmware-dir";
293   paths = lib.mapAttrsToList (name: value: value + /share/esci) plugins;
296 let iscan-data = stdenv.mkDerivation rec {
297   pname = "iscan-data";
298   version = "1.39.2-1";
300   src = fetchurl {
301     urls = [
302       "http://support.epson.net/linux/src/scanner/iscan/iscan-data_${version}.tar.gz"
303       "https://web.archive.org/web/http://support.epson.net/linux/src/scanner/iscan/iscan-data_${version}.tar.gz"
304     ];
305     sha256 = "092qhlnjjgz11ifx6mng7mz20i44gc0nlccrbmw18xr5hipbqqka";
306   };
308   buildInputs = [
309     libxslt
310   ];
312   meta = common_meta;
315 stdenv.mkDerivation rec {
316   pname = "iscan";
317   version = "2.30.4-2";
319   src = fetchurl {
320     urls = [
321       "http://support.epson.net/linux/src/scanner/iscan/iscan_${version}.tar.gz"
322       "https://web.archive.org/web/http://support.epson.net/linux/src/scanner/iscan/iscan_${version}.tar.gz"
323     ];
324     sha256 = "1ma76jj0k3bz0fy06fiyl4di4y77rcryb0mwjmzs5ms2vq9rjysr";
325   };
327   nativeBuildInputs = [ pkg-config libtool makeWrapper ];
328   buildInputs = [
329     gtk2
330     libxml2
331     libusb-compat-0_1
332     sane-backends
333   ];
335   patches = [
336     # Patch for compatibility with libpng versions greater than 10499
337     (fetchpatch {
338       urls = [
339         "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-gfx/iscan/files/iscan-2.28.1.3+libpng-1.5.patch?h=b6e4c805d53b49da79a0f64ef16bb82d6d800fcf"
340         "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"
341       ];
342       sha256 = "04y70qjd220dpyh771fiq50lha16pms98mfigwjczdfmx6kpj1jd";
343     })
344     # Patch iscan to search appropriate folders for firmware files
345     ./firmware_location.patch
346     # Patch deprecated use of sscanf code to use a more modern C99 compatible version
347     ./sscanf.patch
348   ];
349   patchFlags = [ "-p0" ];
351   configureFlags = [ "--enable-dependency-reduction" "--disable-frontend" ];
353   postConfigure = ''
354     echo '#define NIX_ESCI_PREFIX "'${fwdir}'"' >> config.h
355   '';
357   postInstall = ''
358     mkdir -p $out/etc/sane.d
359     cp backend/epkowa.conf $out/etc/sane.d
360     echo "epkowa" > $out/etc/sane.d/dll.conf
361     ln -s ${iscan-data}/share/iscan-data $out/share/iscan-data
362     mkdir -p $out/lib/iscan
363     ln -s ${plugins.network}/lib/iscan/network $out/lib/iscan/network
364   '';
365   postFixup = ''
366     # iscan-registry is a shell script requiring getopt
367     wrapProgram $out/bin/iscan-registry --prefix PATH : ${getopt}/bin
368     registry=$out/bin/iscan-registry;
369   '' +
370   lib.concatStrings (lib.mapAttrsToList
371     (name: value: ''
372       plugin=${value};
373       ${value.passthru.registrationCommand}
374     '')
375     plugins);
376   meta = common_meta // {
377     description = "sane-epkowa backend for some epson scanners";
378     longDescription = ''
379       Includes gui-less iscan (aka. Image Scan! for Linux).
380       Supported hardware: at least :
381     '' +
382     lib.concatStringsSep ", " (lib.mapAttrsToList (name: value: value.passthru.hw) plugins);
383     maintainers = with lib.maintainers; [ symphorien dominikh ];
384   };