summary refs log tree commit diff
path: root/pkgs/misc/drivers/epkowa/default.nix
blob: 29586f3fb55b525c382c23103899fce2c3d35556 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
{stdenv, fetchurl, fetchpatch, makeWrapper, symlinkJoin,
pkgconfig, libtool,
gtk2,
libxml2,
libxslt,
libusb,
sane-backends,
rpm, cpio,
getopt,
patchelf, autoPatchelfHook, gcc
}:

let common_meta = {
    homepage = "http://download.ebz.epson.net/dsc/search/01/search/?OSC=LX";
    license = with stdenv.lib.licenses; epson;
    platforms = with stdenv.lib.platforms; linux;
   };
in
############################
#
#  PLUGINS
#
############################

# adding a plugin for another printer shouldn't be too difficult, but you need the firmware to test...

let plugins = {
  v330 = stdenv.mkDerivation rec {
    name = "iscan-v330-bundle";
    version = "2.30.4";

    src = fetchurl {
      # To find new versions, visit
      # http://download.ebz.epson.net/dsc/search/01/search/?OSC=LX and search for
      # some printer like for instance "WF-7210" to get to the most recent
      # version.  
      # NOTE: Don't forget to update the webarchive link too!
      urls = [
        "https://download2.ebz.epson.net/iscan/plugin/perfection-v330/rpm/x64/iscan-perfection-v330-bundle-${version}.x64.rpm.tar.gz"
        "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"
      ];
      sha256 = "16iq5gmfcgkvcx5hixggxgb8lwin5gjdhnq0zabgpfqg11n2w21q";
    };

    nativeBuildInputs = [ autoPatchelfHook rpm ];

    installPhase = ''
      ${rpm}/bin/rpm2cpio plugins/esci-interpreter-perfection-v330-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
      mkdir $out{,/share,/lib}
      cp -r ./usr/share/{iscan-data,esci}/ $out/share/
      cp -r ./usr/lib64/esci $out/lib
      '';

    passthru = {
      registrationCommand = ''
        $registry --add interpreter usb 0x04b8 0x0142 "$plugin/lib/esci/libesci-interpreter-perfection-v330 $plugin/share/esci/esfwad.bin"
        '';
      hw = "Perfection V330 Photo";
      };
    meta = common_meta // { description = "Plugin to support "+passthru.hw+" scanner in sane."; };
  };
  x770 =   stdenv.mkDerivation rec {
    pname = "iscan-gt-x770-bundle";
    version = "2.30.4";

    nativeBuildInputs = [ autoPatchelfHook rpm ];
    src = fetchurl {
      urls = [
        "https://download2.ebz.epson.net/iscan/plugin/gt-x770/rpm/x64/iscan-gt-x770-bundle-${version}.x64.rpm.tar.gz"
        "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"
      ];
      sha256 = "1cz4z3wz216s77z185m665jcgdslil5gn4dsi118nv1fm17z3jik";
    };
    installPhase = ''
      cd plugins
      ${rpm}/bin/rpm2cpio iscan-plugin-gt-x770-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
      mkdir $out
      cp -r usr/share $out
      cp -r usr/lib64 $out/lib
      mv $out/share/iscan $out/share/esci
      mv $out/lib/iscan $out/lib/esci
      '';
    passthru = {
      registrationCommand = ''
        $registry --add interpreter usb 0x04b8 0x0130 "$plugin/lib/esci/libesint7C $plugin/share/esci/esfw7C.bin"
        '';
      hw = "Perfection V500 Photo";
      };
    meta = common_meta // { description = "iscan esci x770 plugin for "+passthru.hw; };
    };
  f720 = stdenv.mkDerivation rec {
    pname = "iscan-gt-f720-bundle";
    version = "2.30.4";

    nativeBuildInputs= [ autoPatchelfHook ];
    buildInputs = [ gcc.cc.lib ];
    src = fetchurl {
      urls = [
        "https://download2.ebz.epson.net/iscan/plugin/gt-f720/rpm/x64/iscan-gt-f720-bundle-${version}.x64.rpm.tar.gz"
        "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"
      ];
      sha256 = "12rivh00n9mhagy5yjl1m0bv7ypbig6brqkxm0a12xy0mjq7yv8y";
    };
    installPhase = ''
      cd plugins
      ${rpm}/bin/rpm2cpio esci-interpreter-gt-f720-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
      mkdir $out
      cp -r usr/share $out
      cp -r usr/lib64 $out/lib
      '';

    passthru = {
      registrationCommand = ''
        $registry --add interpreter usb 0x04b8 0x0131 "$plugin/lib/esci/libesci-interpreter-gt-f720 $plugin/share/esci/esfw8b.bin"
        '';
      hw = "GT-F720, GT-S620, Perfection V30, Perfection V300 Photo";
      };

    meta = common_meta // { description = "iscan esci f720 plugin for "+passthru.hw; };
  };
  s80 = stdenv.mkDerivation rec {
    pname = "iscan-gt-s80-bundle";
    version = "2.30.4";

    nativeBuildInputs = [ autoPatchelfHook ];
    buildInputs = [ gcc.cc.lib libtool ];
    src = fetchurl {
      urls = [
        "https://download2.ebz.epson.net/iscan/plugin/gt-s80/rpm/x64/iscan-gt-s80-bundle-${version}.x64.rpm.tar.gz"
        "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"
      ];
      sha256 = "1ran75zsxcdci00jakngkz6p9lj4q483hjapmf80p68rzhpmdr5y";
    };
    installPhase = ''
      cd plugins
      ${rpm}/bin/rpm2cpio esci-interpreter-gt-s80-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
      ${rpm}/bin/rpm2cpio iscan-plugin-esdip-*.x86_64.rpm | ${cpio}/bin/cpio -idmv
      mkdir $out
      cp -r usr/share $out
      cp -r usr/lib64 $out/lib
      mkdir $out/share/esci
      '';

    passthru = {
      registrationCommand = ''
        $registry --add interpreter usb 0x04b8 0x0136 "$plugin/lib/esci/libesci-interpreter-gt-s80.so"
        $registry --add interpreter usb 0x04b8 0x0137 "$plugin/lib/esci/libesci-interpreter-gt-s50.so"
        $registry --add interpreter usb 0x04b8 0x0143 "$plugin/lib/esci/libesci-interpreter-gt-s50.so"
        $registry --add interpreter usb 0x04b8 0x0144 "$plugin/lib/esci/libesci-interpreter-gt-s80.so"
        '';
      hw = "ES-D200, ED-D350, ES-D400, GT-S50, GT-S55, GT-S80, GT-S85";
      };

    meta = common_meta // { description = "iscan esci s80 plugin for "+passthru.hw; };
  };
  network = stdenv.mkDerivation rec {
    pname = "iscan-nt-bundle";
    # for the version, look for the driver of XP-750 in the search page
    version = "2.30.4";

    buildInputs = [ stdenv.cc.cc.lib ];
    nativeBuildInputs = [ autoPatchelfHook ];

    src = fetchurl {
      urls = [
        "https://download2.ebz.epson.net/iscan/general/rpm/x64/iscan-bundle-${version}.x64.rpm.tar.gz"
        "https://web.archive.org/web/https://download2.ebz.epson.net/iscan/general/rpm/x64/iscan-bundle-${version}.x64.rpm.tar.gz"
      ];
      sha256 = "1l0y4dy88y91jdq66pxrxqmiwsxwy0rd7x4bh0cw08r4iyhjqprz";
    };
    installPhase = ''
      cd plugins
      ${rpm}/bin/rpm2cpio iscan-network-nt-*.x86_64.rpm | ${cpio}/bin/cpio -idmv

      mkdir $out
      cp -r usr/share $out
      cp -r usr/lib64 $out/lib
      mkdir $out/share/esci
      '';
    passthru = {
      registrationCommand = "";
      hw = "network";
    };

    meta = common_meta // { description = "iscan network plugin"; };
  };
};
in



let fwdir = symlinkJoin {
  name = "esci-firmware-dir";
  paths = stdenv.lib.mapAttrsToList (name: value: value + /share/esci) plugins;
};
in
let iscan-data = stdenv.mkDerivation rec {
  pname = "iscan-data";
  version = "1.39.1-2";

  src = fetchurl {
    urls = [
      "http://support.epson.net/linux/src/scanner/iscan/iscan-data_${version}.tar.gz"
      "https://web.archive.org/web/http://support.epson.net/linux/src/scanner/iscan/iscan-data_${version}.tar.gz"
    ];
    sha256 = "04zrvbnxf1k6zinrd13hwnbzscc3qhmwlvx3k2jhjys2lginw7w4";
  };

  buildInputs = [
    libxslt
  ];

  meta = common_meta;
};
in
stdenv.mkDerivation rec {
  pname = "iscan";
  version = "2.30.4-2";

  src = fetchurl {
    urls = [
      "http://support.epson.net/linux/src/scanner/iscan/iscan_${version}.tar.gz"
      "https://web.archive.org/web/http://support.epson.net/linux/src/scanner/iscan/iscan_${version}.tar.gz"
    ];
    sha256 = "1ma76jj0k3bz0fy06fiyl4di4y77rcryb0mwjmzs5ms2vq9rjysr";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [
    gtk2
    libxml2
    libtool
    libusb
    sane-backends
    makeWrapper
  ];

  patches = [
    (fetchpatch {
      urls = [
        "https://gitweb.gentoo.org/repo/gentoo.git/plain/media-gfx/iscan/files/iscan-2.28.1.3+libpng-1.5.patch?h=b6e4c805d53b49da79a0f64ef16bb82d6d800fcf"
        "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"
      ];
      sha256 = "04y70qjd220dpyh771fiq50lha16pms98mfigwjczdfmx6kpj1jd";
    })
    ./firmware_location.patch
    ];
  patchFlags = "-p0";

  configureFlags = [ "--enable-dependency-reduction" "--disable-frontend"];

  postConfigure = ''
    echo '#define NIX_ESCI_PREFIX "'${fwdir}'"' >> config.h
    '';

  postInstall = ''
    mkdir -p $out/etc/sane.d
    cp backend/epkowa.conf $out/etc/sane.d
    echo "epkowa" > $out/etc/sane.d/dll.conf
    ln -s ${iscan-data}/share/iscan-data $out/share/iscan-data
    mkdir -p $out/lib/iscan
    ln -s ${plugins.network}/lib/iscan/network $out/lib/iscan/network
    '';
  postFixup = ''
    # iscan-registry is a shell script requiring getopt
    wrapProgram $out/bin/iscan-registry --prefix PATH : ${getopt}/bin
    registry=$out/bin/iscan-registry;
    '' +
    stdenv.lib.concatStrings (stdenv.lib.mapAttrsToList (name: value: ''
    plugin=${value};
    ${value.passthru.registrationCommand}
    '') plugins);
  meta = common_meta // {
    description = "sane-epkowa backend for some epson scanners.";
    longDescription = ''
      Includes gui-less iscan (aka. Image Scan! for Linux).
      Supported hardware: at least :
    '' +
    stdenv.lib.concatStringsSep ", " (stdenv.lib.mapAttrsToList (name: value: value.passthru.hw) plugins);
    maintainers = with stdenv.lib.maintainers; [ symphorien ];
  };
}