nixos/garage: add user-given path to ReadWritePaths (#373114)
[NixPkgs.git] / pkgs / misc / cups / drivers / hl3140cw / default.nix
blob01bf330149df2ffa1dbdc9ceeb346daac0aaab7a
2   lib,
3   stdenv,
4   fetchurl,
5   cups,
6   dpkg,
7   gnused,
8   makeWrapper,
9   ghostscript,
10   file,
11   a2ps,
12   coreutils,
13   gawk,
16 let
17   version = "1.1.4-0";
18   cupsdeb = fetchurl {
19     url = "https://download.brother.com/welcome/dlf007070/hl3140cwcupswrapper-${version}.i386.deb";
20     sha256 = "a76281828ca6ee86c63034673577fadcf5f24e8ed003213bdbb6bf47a7aced6f";
21   };
22   srcdir = "hl3140cw_cupswrapper_GPL_source_${version}";
23   cupssrc = fetchurl {
24     url = "https://download.brother.com/welcome/dlf006740/${srcdir}.tar.gz";
25     sha256 = "1wp85rbvbar6rqqkaffymxjpls6jx9m9230dlrpqwy5akiaxf0rl";
26   };
27   lprdeb = fetchurl {
28     url = "https://support.brother.com/g/b/files/dlf/dlf007068/hl3140cwlpr-1.1.2-1.i386.deb";
29     sha256 = "601f392b52ed7080f71b780181823bb8f6abfd0591146b452ba1f23e21f9f865";
30   };
32 stdenv.mkDerivation {
33   pname = "cups-brother-hl3140cw";
34   inherit version;
35   nativeBuildInputs = [
36     makeWrapper
37     dpkg
38   ];
39   buildInputs = [
40     cups
41     ghostscript
42     a2ps
43   ];
45   unpackPhase = ''
46     tar -xvf ${cupssrc}
47   '';
49   buildPhase = ''
50     gcc -Wall ${srcdir}/brcupsconfig/brcupsconfig.c -o brcupsconfpt1
51   '';
53   installPhase = ''
54     # install lpr
55     dpkg-deb -x ${lprdeb} $out
57     substituteInPlace $out/opt/brother/Printers/hl3140cw/lpd/filterhl3140cw \
58       --replace /opt "$out/opt"
59     substituteInPlace $out/opt/brother/Printers/hl3140cw/inf/setupPrintcapij \
60       --replace /opt "$out/opt"
62     sed -i '/GHOST_SCRIPT=/c\GHOST_SCRIPT=gs' $out/opt/brother/Printers/hl3140cw/lpd/psconvertij2
64     patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 $out/opt/brother/Printers/hl3140cw/lpd/brhl3140cwfilter
65     patchelf --set-interpreter ${stdenv.cc.libc}/lib/ld-linux.so.2 $out/usr/bin/brprintconf_hl3140cw
67     wrapProgram $out/opt/brother/Printers/hl3140cw/lpd/psconvertij2 \
68       --prefix PATH ":" ${
69         lib.makeBinPath [
70           gnused
71           coreutils
72           gawk
73         ]
74       }
76     wrapProgram $out/opt/brother/Printers/hl3140cw/lpd/filterhl3140cw \
77       --prefix PATH ":" ${
78         lib.makeBinPath [
79           ghostscript
80           a2ps
81           file
82           gnused
83           coreutils
84         ]
85       }
88     dpkg-deb -x ${cupsdeb} $out
90     substituteInPlace $out/opt/brother/Printers/hl3140cw/cupswrapper/cupswrapperhl3140cw \
91       --replace /opt "$out/opt"
93     mkdir -p $out/lib/cups/filter
94     ln -s $out/opt/brother/Printers/hl3140cw/cupswrapper/cupswrapperhl3140cw $out/lib/cups/filter/cupswrapperhl3140cw
96     ln -s $out/opt/brother/Printers/hl3140cw/cupswrapper/brother_hl3140cw_printer_en.ppd $out/lib/cups/filter/brother_hl3140cw_printer_en.ppd
98     cp brcupsconfpt1 $out/opt/brother/Printers/hl3140cw/cupswrapper/
99     ln -s $out/opt/brother/Printers/hl3140cw/cupswrapper/brcupsconfpt1 $out/lib/cups/filter/brcupsconfpt1
100     ln -s $out/opt/brother/Printers/hl3140cw/lpd/filterhl3140cw $out/lib/cups/filter/brother_lpdwrapper_hl3140cw
102     wrapProgram $out/opt/brother/Printers/hl3140cw/cupswrapper/cupswrapperhl3140cw \
103       --prefix PATH ":" ${
104         lib.makeBinPath [
105           gnused
106           coreutils
107           gawk
108         ]
109       }
110   '';
112   meta = {
113     homepage = "http://www.brother.com/";
114     description = "Brother hl3140cw printer driver";
115     sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
116     license = lib.licenses.unfree;
117     platforms = lib.platforms.linux;
118     downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=eu_ot&lang=en&prod=hl3140cw_us_eu&os=128";
119   };