# Brother DCP-572DW wrapper

**URL:** https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113
**Category:** Help
**Created:** [July 13, 2020, 1:38pm UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113 "2020-07-13T13:38:06Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mradke](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mradke/32/1986_2.png) [@mradke](https://discourse.nixos.org/u/mradke)
#### Post date: [July 13, 2020, 1:38pm UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/1 "2020-07-13T13:38:06Z")

</div>

I’d like to install the aforementioned printer with a custom nix expression:

```auto
{ stdenv, fetchurl, cups, dpkg, ghostscript, a2ps, coreutils, gnused, gawk, file, makeWrapper }:

stdenv.mkDerivation rec {
  pname = "dcp-j572dw-cupswrapper";
  version = "1.0.5-0";

  src = fetchurl {
    url = "https://download.brother.com/welcome/dlf103777/dcpj572dwpdrv-${version}.i386.deb";
    sha256 = "7166e4c46e42c24dc9342eccf014547dda61580c91be4293e821a196343a8fa7";
  };

  nativeBuildInputs = [makeWrapper];
  buildInputs = [cups ghostscript dpkg a2ps];

  dontUnpack = true;

  installPhase = ''
    dpkg-deb -x $src $out

    patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux.so.2 $out/opt/brother/Printers/dcpj572dw/lpd/brdcpj572dwfilter

    mkdir -p $out/lib/cups/filter/
    ln -s $out/opt/brother/Printers/dcp572dw/lpd/filter_dcpj572dw $out/lib/cups/filter/brother_lpdwrapper_dcpj572dw

    substituteInPlace $out/opt/brother/Printers/dcpj572dw/cupswrapper/brother_lpdwrapper_dcpj572dw \
    --replace /opt "$out/opt" 

    substituteInPlace $out/opt/brother/Printers/dcpj572dw/cupswrapper/cupswrapperdcpj572dw \
    --replace /opt "$out/opt" 
    '';

  meta = {
    homepage = "http://www.brother.com/";
    description = "Brother DCP-J572DW LPR driver";
    license = stdenv.lib.licenses.unfree;
    platforms = stdenv.lib.platforms.linux;
    downloadPage = "http://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=mfcj470dw_us_eu_as&os=128";
  };
}

```

It is modelled after: [https://github.com/NixOS/nixpkgs/blob/a3389443b3d6c6857554721dd1b1f61367878bcc/pkgs/misc/cups/drivers/mfcj470dwlpr/default.nix](https://github.com/NixOS/nixpkgs/blob/a3389443b3d6c6857554721dd1b1f61367878bcc/pkgs/misc/cups/drivers/mfcj470dwlpr/default.nix)

I’m probably doing all kinds of things wrong, even though: this way it a least installs something 😃

Any pointers on how to proceed?

* * *

On another note: can anyone recommend a networked printer/scanner combination that works out of the box with NixOS?

---

<div class="post-metadata">

### Author: ![mradke](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mradke/32/1986_2.png) [@mradke](https://discourse.nixos.org/u/mradke)
#### Post date: [August 31, 2021, 6:01am UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/2 "2021-08-31T06:01:58Z")

</div>

Ok, so my current setup is the following:

```auto
{ pkgsi686Linux
, stdenv
, fetchurl
, dpkg
, makeWrapper
, coreutils
, ghostscript
, gnugrep
, gnused
, which
, perl
, lib
}:

let
  model = "dcpj572dw";
  version = "1.0.5-0";
  src = fetchurl {
    url = "https://download.brother.com/welcome/dlf103777/dcpj572dwpdrv-${version}.i386.deb";
    sha256 = "7166e4c46e42c24dc9342eccf014547dda61580c91be4293e821a196343a8fa7";
  };
  reldir = "opt/brother/Printers/${model}/";

in rec {
  driver = pkgsi686Linux.stdenv.mkDerivation rec {
    inherit src version;
    name = "${model}drv-${version}";

    nativeBuildInputs = [dpkg makeWrapper];

    unpackPhase = "dpkg-deb -x $src $out";

    installPhase = ''
      dir="$out/${reldir}"
      substituteInPlace $dir/lpd/filter_${model} \
        --replace /usr/bin/perl ${perl}/bin/perl \
        --replace "BR_PRT_PATH =~" "BR_PRT_PATH = \"$dir\"; #" \
        --replace "PRINTER =~" "PRINTER = \"${model}\"; #"
      wrapProgram $dir/lpd/filter_${model} \
        --prefix PATH : ${stdenv.lib.makeBinPath [
          coreutils ghostscript gnugrep gnused which
        ]}
    # need to use i686 glibc here, these are 32bit proprietary binaries
    patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      $dir/lpd/br${model}filter
    '';

    meta = {
      description = "Brother ${lib.strings.toUpper model} driver";
      homepage = "http://www.brother.com/";
      license = stdenv.lib.licenses.unfree;
      platforms = ["x86_64-linux" "i686-linux"];
    };
  };

  cupswrapper = stdenv.mkDerivation rec {
    inherit version src;
    name = "${model}cupswrapper-${version}";

    nativeBuildInputs = [dpkg makeWrapper];

    unpackPhase = "dpkg-deb -x $src $out";

    installPhase = ''
      basedir=${driver}/${reldir}
      dir=$out/${reldir}
      substituteInPlace $dir/cupswrapper/brother_lpdwrapper_${model} \
        --replace /usr/bin/perl ${perl}/bin/perl \
        --replace "basedir =~" "basedir = \"$basedir\"; #" \
        --replace "PRINTER =~" "PRINTER = \"${model}\"; #"
      wrapProgram $dir/cupswrapper/brother_lpdwrapper_${model} \
        --prefix PATH : ${stdenv.lib.makeBinPath [coreutils gnugrep gnused]}
      mkdir -p $out/lib/cups/filter
      mkdir -p $out/share/cups/model
      ln $dir/cupswrapper/brother_lpdwrapper_${model} $out/lib/cups/filter
      ln $dir/cupswrapper/brother_${model}_printer_en.ppd $out/share/cups/model
    '';

    meta = {
      description = "Brother ${lib.strings.toUpper model} CUPS wrapper driver";
      homepage = "http://www.brother.com/";
      license = stdenv.lib.licenses.gpl2;
      platforms = ["x86_64-linux" "i686-linux"];
    };
  };
}

```

This makes it at least possible to install the driver (as in: it is selectable in the CUPS web gui) but it won’t print. It simply does nothing.

I already tried to follow the advice given here: [Gentoo Forums :: View topic - How to install an Brother (DCP-J572) Printer correctly?](https://forums.gentoo.org/viewtopic-t-1091898-start-0.html) and configure it via lpd.

> I was able to configure my Brother MFC-J4620DW with CUPS GUI over WIFI by choosing:  
> Internet Printing Protocol (ipp)  
> For the connection type and then entering the details as:  
> lpd://[IP\_ADDRESS]/queue  
> Then just continue setup & choose the correct driver, defaults, etc.

While this looks really promising (you can see many options in the gui that look sensible) it still doesn’t print the test page at all.

Any pointers on how to debug this?

---

<div class="post-metadata">

### Author: ![peterhoeg](https://discourse.nixos.org/user_avatar/discourse.nixos.org/peterhoeg/32/137_2.png) [@peterhoeg](https://discourse.nixos.org/u/peterhoeg)
#### Post date: [August 31, 2021, 6:37am UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/3 "2021-08-31T06:37:13Z")

</div>

So this is slightly off-topic, but I’m hoping it can help you.

I have a Brother printer too, and it turns out that it supports “IPP Everywhere” which was completely new to me.

So this is the only config I use to get mine working:

```auto
hardware =
  let
    brother = "Brother_HL-3170CDW_NixOS";
    hostName = "printer.home.hoeg.com";
  in
  {
    printers = {
      ensureDefaultPrinter = brother;
      ensurePrinters = [
        {
          name = brother;
          deviceUri = "ipp://${hostName}/ipp";
          model = "everywhere";
          description = lib.replaceStrings ["_"] [" "] brother;
          location = "Study";
        }
      ];
    };
  };

```

No fiddling with strange wrappers or drivers - IPP Everywhere _just_ works.

---

<div class="post-metadata">

### Author: ![mradke](https://discourse.nixos.org/user_avatar/discourse.nixos.org/mradke/32/1986_2.png) [@mradke](https://discourse.nixos.org/u/mradke)
#### Post date: [August 31, 2021, 8:01am UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/4 "2021-08-31T08:01:56Z")

</div>

Ha. Incredible… that really works 😃  
Thank you so much.

---

<div class="post-metadata">

### Author: ![peterhoeg](https://discourse.nixos.org/user_avatar/discourse.nixos.org/peterhoeg/32/137_2.png) [@peterhoeg](https://discourse.nixos.org/u/peterhoeg)
#### Post date: [August 31, 2021, 8:25am UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/5 "2021-08-31T08:25:37Z")

</div>

I don’t recall how I stumbled over IPP Everywhere but it definitely should be getting more attention.

---

<div class="post-metadata">

### Author: ![igel](https://discourse.nixos.org/user_avatar/discourse.nixos.org/igel/32/3964_2.png) [@igel](https://discourse.nixos.org/u/igel)
#### Post date: [March 19, 2022, 11:09am UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/6 "2022-03-19T11:09:47Z")

</div>

I added the code to the config but there is no printer shown. (21.11)  
What else needs to be in the configuration?

---

<div class="post-metadata">

### Author: ![peterhoeg](https://discourse.nixos.org/user_avatar/discourse.nixos.org/peterhoeg/32/137_2.png) [@peterhoeg](https://discourse.nixos.org/u/peterhoeg)
#### Post date: [March 21, 2022, 6:49am UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/7 "2022-03-21T06:49:16Z")

</div>

Probably this:

services.printing.enable = true;

---

<div class="post-metadata">

### Author: ![skane](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/s/bbe5ce/32.png) [@skane](https://discourse.nixos.org/u/skane)
#### Post date: [October 14, 2024, 8:55pm UTC](https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/8 "2024-10-14T20:55:28Z")

</div>

Just like magic. Solved the issue I’ve been struggling with for a month. This should be in the NixOs Cups docs.
