Declarative Printer Setup Missing Driver

Hello Nix Wizards

I got this engenious setup from Mr. Hoeg here on the forum: https://discourse.nixos.org/t/brother-dcp-572dw-wrapper/8113/3

It works so far for me. Only problem is, that model = "everywhere"; does setup my printer to only grayscale.
So I changed to model = "drv:///cupsfilters.drv/pwgrast.ppd";, this is also not perfect as the two sided printing does not work correctly. As drv:///cupsfilters.drv/pwgrast.ppd is some general driver.

When I manually change the driver to everywhere in the HP driver menu then everything works:

How can I find this driver and apply it correctly to model = "everywhere";?

Thank you in advance for your answer!

Here’s the whole shebang:

{ config, lib, pkgs, ... }:

# check existing printers with lpstat -s and remove printers with lpadmin -x <printer-name>

{
  hardware =
    let
      printer = "HP_Color_LaserJet_Pro_M454dw";
      hostName = "192.168.178.3";
    in
      {
        printers = {
          ensureDefaultPrinter = printer;
          ensurePrinters = [
            {
              name = printer;
              deviceUri = "ipp://${hostName}";
              model = "drv:///cupsfilters.drv/pwgrast.ppd";  # Location of the ppd driver file for the printer. lpinfo -m shows a list of supported models.
              description = lib.replaceStrings [ "_" ] [ " " ] printer;
              location = "Home";
            }
          ];
        };
      };
}

I suggest taking a look at /etc/cups/printers.conf to see what the difference is between what the nixos module does (it should have created a systemd service named ensure-printers.service) and what you did manually.

1 Like

Thank you Peter! Will check it out …

@gemstraam Were you ever able to figure this out? I have the same issue with a Brother HL-L3290CDW printer where using model = "everywhere" or model = "drv:///cupsfilters.drv/pwgrast.ppd" does not allow two-sided printing. However, if I manually add the printer through the CUPS web interface using IPP Everywhere it works.

If I could get MakeModel HL-L3290CDW series - IPP Everywhere to appear in /etc/cups/printers.conf I think that would solve it.

this are my settings as a module, works w/o any flaws, @peterhoeg is a mf’ing genius who’s all over the nix repos, so you betch it works :wink:

{ config, lib, pkgs, ... }:

# https://nixos.wiki/wiki/Printing
# https://developers.hp.com/hp-linux-imaging-and-printing
#
# Most modern printers are capable of the IPP everywhere protocol, ie printing without installing drivers.
# This is notably the case of all WiFi printers marketed as Apple-compatible
# see https://support.apple.com/en-ca/HT201311
#
# Check existing printers with lpstat -s and remove printers with lpadmin -x <printer-name>
# lpoptions [-p printername] -l shows supported PPD options for the given printer.
#
# HP Color LaserJet Pro M454dw
#
# CUPS:
# http://localhost:631/

{
  services.printing.drivers = with pkgs; [ hplip ];

  hardware =
    let
      printer = "HP_Color_LaserJet_Pro_M454dw";
      hostName = "192.168.1.25";
    in
      {
        printers = {
          ensureDefaultPrinter = printer;
          ensurePrinters = [
            {
              name = printer;
              deviceUri = "ipp://${hostName}";
              model = "HP/hp-color_laserjet_pro_m453-4-ps.ppd.gz";  # Location of the ppd driver file for the printer. lpinfo -m shows a list of supported models.
              description = lib.replaceStrings [ "_" ] [ " " ] printer;
              location = "Home";
              ppdOptions = {      # lpoptions [-p printername] -l shows supported PPD options for the given printer.
                PageSize = "A4";
              };
            }
          ];
        };
      };
}

hope this helps …

Thank you both @gemstraam and @peterhoeg :slight_smile: I was able to get this working by specifying a PPD file for model. My particular printer model doesn’t have a PPD file that I could find, but it turns out that CUPS generated one for me when I added the printer through the web UI. I found it at /etc/cups/ppd. I then added it as a driver to my system and specified it in model. Here’s my final .nix file:

{ lib, pkgs, ... }:

{
  # Manually Adding Printer (without using this derivation):
  # Open the CUPS dashboard, add a printer at ipp://your-printer-ip,
  # and make sure to select the "IPP Everywhere" driver (NOT "Generic IPP
  # Everywhere")

  # https://nixos.wiki/wiki/Printing
  # https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/5

  # For debugging purposes, the data folder used by CUPS (containing the drivers and more)
  # can be obtained by looking in the environment variable $CUPS_DATADIR
  # (the contents of $out/share/cups/ contained in your drivers are linked in this folder).

  services.printing.enable = true;
  services.printing.drivers = [
    # This PPD file was generated by CUPS when creating a new LPD/LPR Printer
    # from the Web UI. It was stored in /etc/cups/ppd and I copied it to this Nix repo.
    (pkgs.writeTextDir "share/cups/model/Brother_HL-L3290CDW.ppd" (builtins.readFile ./Brother_HL-L3290CDW.ppd))
  ];

  hardware =
    let
      brother = "Brother_HL-L3290CDW";
      hostName = "PrinterIpAddress";
    in
    {
      printers = {
      ensurePrinters = [
        {
          name = "${brother}";
          deviceUri = "ipp://${hostName}";
          model = "${brother}.ppd"; # Location of the PPD driver file for the printer.
                                    # lpinfo -m shows a list of supported models.
          location = "Home";
          description = lib.replaceStrings [ "_" ] [ " " ] brother;
          ppdOptions = {
            PageSize = "Letter";
            Duplex = "DuplexNoTumble"; # Double-sided along the long edge
            Resolution = "600dpi";
            PrintQuality = "4";
            PwgRasterDocumentType = "Rgb_8";
          };
        }
      ];
      ensureDefaultPrinter = "${brother}";
    };
  };
}

I continue to be amazed at the generosity of time of this community. Nix/NixOS is hard, but I’ve found time and again people are willing to answer questions and help solve problems. Thanks again!

My particular printer model doesn’t have a PPD file that I could find

You can get PPDs directly from Brother for at least some models:

In order to decompress the file you will need this:

1 Like

Thank you, @peterhoeg! I was able to use the official Brother PPD using these instructions and your derivation :slight_smile:

Just a quick note for anyone that comes across this later, you still need to run the .exe in Windows (unless there’s a different way that I’m not aware of?) after which you can use msexpand (part of the mscompress package) to decompress the pp_ file that gets extracted from the .exe.

7zz x name-of-exe

No windows needed!

1 Like

And… of course there’s a way :smile: Thanks!