19 stdenv.mkDerivation rec {
20 pname = "cups-brother-${model}";
22 lprVersion = "1.1.2-1";
25 cupsFileNo = "006743";
29 url = "https://download.brother.com/welcome/dlf${cupsFileNo}/${model}_cupswrapper_GPL_source_${version}.tar.gz";
30 hash = "sha256-E3GSwiMRkuiCIJYkDozoYUPfOqvopPqPPQt1uaMDEAU=";
34 url = "https://download.brother.com/welcome/dlf${lprFileNo}/${model}lpr-${lprVersion}.i386.deb";
35 hash = "sha256-N1GjQHth5k4qhbfWLInzub9DcNsee4gKc3EW2WIfrko=";
44 dpkg-deb -x ${lprdeb} $out
48 substituteInPlace brcupsconfig/brcups_commands.h \
49 --replace-fail "brprintconf[30]=\"" "brprintconf[130]=\"$out/usr/bin/"
51 substituteInPlace brcupsconfig/brcupsconfig.c \
52 --replace-fail "exec[300]" "exec[400]"
55 makeFlags = [ "-C brcupsconfig" ];
61 dir=$out/opt/brother/Printers/${model}
63 # Extract the true brother_lpdwrapper_MODEL filter embedded in cupswrapperMODEL by
64 # slicing out the relevant parts for the writing the embedded file, then running that.
65 sed -n -e '/tmp_filter=/c\tmp_filter=lpdwrapper' -e ' 1,/device_model=/p ; /<<!ENDOFWFILTER/,/!ENDOFWFILTER/p ; ' \
66 cupswrapper/cupswrapper${model} > lpdwrapperbuilder
69 mkdir -p $out/lib/cups/filter
70 cp lpdwrapper $out/lib/cups/filter/brother_lpdwrapper_${model}
72 mkdir -p $out/share/cups/model/Brother
73 cp PPD/brother_${model}_printer_en.ppd $out/share/cups/model/Brother/brother_${model}_printer_en.ppd
75 mkdir -p $dir/cupswrapper/
76 cp brcupsconfig/brcupsconfpt1 $dir/cupswrapper/
83 interpreter=${pkgsi686Linux.glibc.out}/lib/ld-linux.so.2
85 substituteInPlace $dir/lpd/filter${model} \
86 --replace-fail /opt "$out/opt"
87 substituteInPlace $dir/inf/setupPrintcapij \
88 --replace-fail /opt "$out/opt" \
89 --replace-fail printcap.local printcap
91 wrapProgram $dir/lpd/filter${model} \
102 wrapProgram $dir/inf/setupPrintcapij \
110 wrapProgram $dir/lpd/psconvertij2 \
121 patchelf --set-interpreter "$interpreter" "$dir/lpd/br${model}filter"
122 patchelf --set-interpreter "$interpreter" "$out/usr/bin/brprintconf_${model}"
124 wrapProgram $dir/lpd/br${model}filter \
125 --set LD_PRELOAD "${pkgsi686Linux.libredirect}/lib/libredirect.so" \
126 --set NIX_REDIRECTS "/opt=$out/opt"
128 wrapProgram $out/usr/bin/brprintconf_${model} \
129 --set LD_PRELOAD "${pkgsi686Linux.libredirect}/lib/libredirect.so" \
130 --set NIX_REDIRECTS "/opt=$out/opt"
133 substituteInPlace $out/lib/cups/filter/brother_lpdwrapper_${model} \
134 --replace-fail /opt/brother/Printers/${model} "$dir" \
135 --replace-fail /usr/bin/psnup "${psutils}/bin/psnup" \
136 --replace-fail /usr/share/cups/model/Brother "$out/share/cups/model/Brother"
138 wrapProgram $out/lib/cups/filter/brother_lpdwrapper_${model} \
150 homepage = "https://www.brother.com/";
151 description = "Brother ${model} printer driver";
152 sourceProvenance = with sourceTypes; [
156 license = with licenses; [
164 downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=${model}_all&os=128";
165 maintainers = with maintainers; [ luna_1024 ];