@@ -0,0 +1,73 @@
1+{ stdenv
2+, lib
3+, fetchurl
4+, dpkg
5+, makeWrapper
6+, coreutils
7+, file
8+, gawk
9+, ghostscript
10+, gnused
11+, pkgsi686Linux
12+}:
13+
14+stdenv.mkDerivation rec {
15+ pname = "mfc9140cdnlpr";
16+ version = "1.1.2-1";
17+
18+ src = fetchurl {
19+ url = "https://download.brother.com/welcome/dlf100405/${pname}-${version}.i386.deb";
20+ sha256 = "1wqx8njrv078fc3vlq90qyrfg3cw9kr9m6f3qvfnkhq1f95fbslh";
21+ };
22+
23+ unpackPhase = ''
24+ dpkg-deb -x $src $out
25+ '';
26+
27+ nativeBuildInputs = [
28+ dpkg
29+ makeWrapper
30+ ];
31+
32+ dontBuild = true;
33+
34+ installPhase = ''
35+ dir=$out/opt/brother/Printers/mfc9140cdn
36+
37+ patchelf --set-interpreter ${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2 $dir/lpd/brmfc9140cdnfilter
38+
39+ wrapProgram $dir/inf/setupPrintcapij \
40+ --prefix PATH : ${lib.makeBinPath [
41+ coreutils
42+ ]}
43+
44+ substituteInPlace $dir/lpd/filtermfc9140cdn \
45+ --replace "BR_CFG_PATH=" "BR_CFG_PATH=\"$dir/\" #" \
46+ --replace "BR_LPD_PATH=" "BR_LPD_PATH=\"$dir/\" #"
47+
48+ wrapProgram $dir/lpd/filtermfc9140cdn \
49+ --prefix PATH : ${lib.makeBinPath [
50+ coreutils
51+ file
52+ ghostscript
53+ gnused
54+ ]}
55+
56+ substituteInPlace $dir/lpd/psconvertij2 \
57+ --replace '`which gs`' "${ghostscript}/bin/gs"
58+
59+ wrapProgram $dir/lpd/psconvertij2 \
60+ --prefix PATH : ${lib.makeBinPath [
61+ gnused
62+ gawk
63+ ]}
64+ '';
65+
66+ meta = with lib; {
67+ description = "Brother MFC-9140CDN LPR printer driver";
68+ homepage = "http://www.brother.com/";
69+ license = licenses.unfree;
70+ maintainers = with maintainers; [ hexa ];
71+ platforms = [ "i686-linux" "x86_64-linux" ];
72+ };
73+}