1{
2 lib,
3 stdenv,
4 fetchurl,
5 cups,
6 dpkg,
7 ghostscript,
8 a2ps,
9 coreutils,
10 gnused,
11 gawk,
12 file,
13 makeWrapper,
14}:
15
16stdenv.mkDerivation rec {
17 pname = "mfcj470dw-cupswrapper";
18 version = "3.0.0-1";
19
20 src = fetchurl {
21 url = "https://download.brother.com/welcome/dlf006843/mfcj470dwlpr-${version}.i386.deb";
22 sha256 = "7202dd895d38d50bb767080f2995ed350eed99bc2b7871452c3c915c8eefc30a";
23 };
24
25 nativeBuildInputs = [ makeWrapper ];
26 buildInputs = [
27 cups
28 ghostscript
29 dpkg
30 a2ps
31 ];
32
33 dontUnpack = true;
34
35 installPhase = ''
36 dpkg-deb -x $src $out
37
38 substituteInPlace $out/opt/brother/Printers/mfcj470dw/lpd/filtermfcj470dw \
39 --replace /opt "$out/opt" \
40
41 sed -i '/GHOST_SCRIPT=/c\GHOST_SCRIPT=gs' $out/opt/brother/Printers/mfcj470dw/lpd/psconvertij2
42
43 patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 $out/opt/brother/Printers/mfcj470dw/lpd/brmfcj470dwfilter
44
45 mkdir -p $out/lib/cups/filter/
46 ln -s $out/opt/brother/Printers/mfcj470dw/lpd/filtermfcj470dw $out/lib/cups/filter/brother_lpdwrapper_mfcj470dw
47
48 wrapProgram $out/opt/brother/Printers/mfcj470dw/lpd/psconvertij2 \
49 --prefix PATH ":" ${
50 lib.makeBinPath [
51 gnused
52 coreutils
53 gawk
54 ]
55 }
56
57 wrapProgram $out/opt/brother/Printers/mfcj470dw/lpd/filtermfcj470dw \
58 --prefix PATH ":" ${
59 lib.makeBinPath [
60 ghostscript
61 a2ps
62 file
63 gnused
64 coreutils
65 ]
66 }
67 '';
68
69 meta = {
70 homepage = "http://www.brother.com/";
71 description = "Brother MFC-J470DW LPR driver";
72 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
73 license = lib.licenses.unfree;
74 platforms = lib.platforms.linux;
75 downloadPage = "http://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=mfcj470dw_us_eu_as&os=128";
76 maintainers = [ lib.maintainers.yochai ];
77 };
78}