@@ -0,0 +1,68 @@
1+{stdenv, fetchurl, cups, dpkg, gnused, makeWrapper, ghostscript, file, a2ps, coreutils, gawk, perl, gnugrep, which}:
2+
3+let
4+ version = "3.2.0-1";
5+ lprdeb = fetchurl {
6+ url = "https://download.brother.com/welcome/dlf101912/hll2340dlpr-${version}.i386.deb";
7+ sha256 = "c0ae98b49b462cd8fbef445550f2177ce9d8bf627c904e182daa8cbaf8781e50";
8+ };
9+
10+ cupsdeb = fetchurl {
11+ url = "https://download.brother.com/welcome/dlf101913/hll2340dcupswrapper-${version}.i386.deb";
12+ sha256 = "8aa24a6a825e3a4d5b51778cb46fe63032ec5a731ace22f9ef2b0ffcc2033cc9";
13+ };
14+
15+in
16+stdenv.mkDerivation {
17+ name = "cups-brother-hll2340dw";
18+
19+ nativeBuildInputs = [ makeWrapper ];
20+ buildInputs = [ cups ghostscript dpkg a2ps ];
21+
22+ dontUnpack = true;
23+
24+ installPhase = ''
25+ mkdir -p $out
26+ dpkg-deb -x ${cupsdeb} $out
27+ dpkg-deb -x ${lprdeb} $out
28+
29+ substituteInPlace $out/opt/brother/Printers/HLL2340D/lpd/filter_HLL2340D \
30+ --replace /opt "$out/opt" \
31+ --replace /usr/bin/perl ${perl}/bin/perl \
32+ --replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$out/opt/brother/Printers/HLL2340D/\"; #" \
33+ --replace "PRINTER =~" "PRINTER = \"HLL2340D\"; #"
34+
35+ patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
36+ $out/opt/brother/Printers/HLL2340D/lpd/brprintconflsr3
37+ patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
38+ $out/opt/brother/Printers/HLL2340D/lpd/rawtobr3
39+
40+ for f in \
41+ $out/opt/brother/Printers/HLL2340D/cupswrapper/brother_lpdwrapper_HLL2340D \
42+ $out/opt/brother/Printers/HLL2340D/cupswrapper/paperconfigml1 \
43+ ; do
44+ wrapProgram $f \
45+ --prefix PATH : ${stdenv.lib.makeBinPath [
46+ coreutils ghostscript gnugrep gnused
47+ ]}
48+ done
49+
50+ mkdir -p $out/lib/cups/filter/
51+ ln -s $out/opt/brother/Printers/HLL2340D/lpd/filter_HLL2340D $out/lib/cups/filter/brother_lpdwrapper_HLL2340D
52+
53+ mkdir -p $out/share/cups/model
54+ ln -s $out/opt/brother/Printers/HLL2340D/cupswrapper/brother-HLL2340D-cups-en.ppd $out/share/cups/model/
55+
56+ wrapProgram $out/opt/brother/Printers/HLL2340D/lpd/filter_HLL2340D \
57+ --prefix PATH ":" ${ stdenv.lib.makeBinPath [ ghostscript a2ps file gnused gnugrep coreutils which ] }
58+ '';
59+
60+ meta = with stdenv.lib; {
61+ homepage = http://www.brother.com/;
62+ description = "Brother hl-l2340dw printer driver";
63+ license = licenses.unfree;
64+ platforms = platforms.linux;
65+ downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=us&lang=es&prod=hll2340dw_us_eu_as&os=128&flang=English";
66+ maintainers = [ maintainers.qknight ];
67+ };
68+}