Background
With help from IRC, I was able to set up my Brother HL-L2350DW printer on NixOS by imitating the existing derivation for hll2390dw-cups. Then @samueldr, who maintains that derivation, pointed out that his printer prints letter files as if set to A4, and I noticed my printer was doing the same. He shared his fix, which also worked for me for the HL-L2350DW. The fix is a bit of a hack, which in my understanding is why he hasn't submitted it to nixpkgs. I'm filing this issue to document it and to share a working derivation for the HL-L2350DW printer.
Issue description
The current Brother HL-L2390DW driver (hll2390dw-cups) prints as if set to A4 when set to letter, causing text to run off the right and bottom sides of the paper.
Steps to reproduce
- Put
hll2390dw-cups in services.printing.drivers and rebuild nixos.
- Open the cups web interface and add the printer. (The driver appears immediately.)
- Choose a pdf file to print, check that it is letter size with
pdfinfo [filename].
- Print, e.g. with
lpr -p [printername] [filename].
The text will run off the right and bottom of the page.
Known fix
See @samueldr's fix here.
Notes on Brother HL-L2350DW
Below is a working derivation for the Brother HL-L2350DW. It is a copy of the derivation for hll2390dw-cups, with the download url and printer name changed. I am also including @samueldr's fix.
For other printers in the HL-L23x0DW line, I would suggest downloading the .deb package from the Brother support site. If its version is 4.0.0-1, it is likely essentially the same as the package for the HL-L2390DW and HL-L2350DW, and an equivalent derivation should work; just modify the fetchurl section (use nix-prefetch-url to get the hash) and the printer name. You can put the following in its own .nix file (say, printer.nix) and call it from configuration.nix with something like services.printing.drivers = [ (pkgs.callPackage ./printer.nix {}) ];.
Derivation for HL-L2350DW:
{ stdenv, fetchurl, makeWrapper
, cups
, dpkg
, a2ps, ghostscript, gnugrep, gnused, coreutils, file, perl, which
}:
stdenv.mkDerivation rec {
name = "hll2350dw-cups-${version}";
version = "4.0.0-1";
src = fetchurl {
url = "https://download.brother.com/welcome/dlf103566/hll2350dwpdrv-${version}.i386.deb";
sha256 = "0b7hhln105agc3rwpi7cjlx5nf4d2yk9iksahdv3725nnd06lg46";
};
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ cups ghostscript dpkg a2ps ];
unpackPhase = ":";
installPhase = ''
dpkg-deb -x $src $out
substituteInPlace $out/opt/brother/Printers/HLL2350DW/lpd/lpdfilter \
--replace /opt "$out/opt" \
--replace /usr/bin/perl ${perl}/bin/perl \
--replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$out\"; #" \
--replace "PRINTER =~" "PRINTER = \"HLL2350DW\"; #"
# FIXME : Allow i686 and armv7l variations to be setup instead.
_PLAT=x86_64
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
$out/opt/brother/Printers/HLL2350DW/lpd/$_PLAT/brprintconflsr3
patchelf --set-interpreter $(cat $NIX_CC/nix-support/dynamic-linker) \
$out/opt/brother/Printers/HLL2350DW/lpd/$_PLAT/rawtobr3
ln -s $out/opt/brother/Printers/HLL2350DW/lpd/$_PLAT/brprintconflsr3 $out/opt/brother/Printers/HLL2350DW/lpd/brprintconflsr3
ln -s $out/opt/brother/Printers/HLL2350DW/lpd/$_PLAT/rawtobr3 $out/opt/brother/Printers/HLL2350DW/lpd/rawtobr3
for f in \
$out/opt/brother/Printers/HLL2350DW/cupswrapper/lpdwrapper \
$out/opt/brother/Printers/HLL2350DW/cupswrapper/paperconfigml2 \
; do
#substituteInPlace $f \
wrapProgram $f \
--prefix PATH : ${stdenv.lib.makeBinPath [
coreutils ghostscript gnugrep gnused
]}
done
# Hack suggested by samueldr.
sed -i"" "s;A4;Letter;g" $out/opt/brother/Printers/HLL2350DW/inf/brHLL2350DWrc
mkdir -p $out/lib/cups/filter/
ln -s $out/opt/brother/Printers/HLL2350DW/lpd/lpdfilter $out/lib/cups/filter/brother_lpdwrapper_HLL2350DW
mkdir -p $out/share/cups/model
ln -s $out/opt/brother/Printers/HLL2350DW/cupswrapper/brother-HLL2350DW-cups-en.ppd $out/share/cups/model/
wrapProgram $out/opt/brother/Printers/HLL2350DW/lpd/lpdfilter \
--prefix PATH ":" ${ stdenv.lib.makeBinPath [ ghostscript a2ps file gnused gnugrep coreutils which ] }
'';
meta = with stdenv.lib; {
homepage = "https://www.brother.com/";
description = "Brother HL-L2350DW combined print driver";
license = licenses.unfree;
platforms = [
"x86_64-linux"
];
downloadPage = "https://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=hll2350dw_us_eu_as&os=128";
};
}
Next steps
These are just ideas, to see if it makes sense to include @samueldr's fix in the hll2390dw-cups derivation, and to see if it makes sense to add a hll2350dw-cups derivation.
- Check whether one can still print A4 with @samueldr's fix.
- Check whether this A4/letter issue is also an issue in distributions that can install the official Brother packages directly, like Debian. (Maybe there is just a CUPS configuration step we're both missing.)
Background
With help from IRC, I was able to set up my Brother HL-L2350DW printer on NixOS by imitating the existing derivation for
hll2390dw-cups. Then @samueldr, who maintains that derivation, pointed out that his printer prints letter files as if set to A4, and I noticed my printer was doing the same. He shared his fix, which also worked for me for the HL-L2350DW. The fix is a bit of a hack, which in my understanding is why he hasn't submitted it to nixpkgs. I'm filing this issue to document it and to share a working derivation for the HL-L2350DW printer.Issue description
The current Brother HL-L2390DW driver (
hll2390dw-cups) prints as if set to A4 when set to letter, causing text to run off the right and bottom sides of the paper.Steps to reproduce
hll2390dw-cupsinservices.printing.driversand rebuild nixos.pdfinfo [filename].lpr -p [printername] [filename].The text will run off the right and bottom of the page.
Known fix
See @samueldr's fix here.
Notes on Brother HL-L2350DW
Below is a working derivation for the Brother HL-L2350DW. It is a copy of the derivation for
hll2390dw-cups, with the download url and printer name changed. I am also including @samueldr's fix.For other printers in the HL-L23x0DW line, I would suggest downloading the .deb package from the Brother support site. If its version is 4.0.0-1, it is likely essentially the same as the package for the HL-L2390DW and HL-L2350DW, and an equivalent derivation should work; just modify the
fetchurlsection (usenix-prefetch-urlto get the hash) and the printer name. You can put the following in its own .nix file (say,printer.nix) and call it fromconfiguration.nixwith something likeservices.printing.drivers = [ (pkgs.callPackage ./printer.nix {}) ];.Derivation for HL-L2350DW:
Next steps
These are just ideas, to see if it makes sense to include @samueldr's fix in the
hll2390dw-cupsderivation, and to see if it makes sense to add ahll2350dw-cupsderivation.