# Declarative Printer Setup Missing Driver

**URL:** https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777
**Category:** Help
**Created:** [October 3, 2023, 4:46am UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777 "2023-10-03T04:46:41Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![gemstraam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gemstraam/32/7361_2.png) [@gemstraam](https://discourse.nixos.org/u/gemstraam)
#### Post date: [October 3, 2023, 4:46am UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/1 "2023-10-03T04:46:41Z")

</div>

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](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:

 ![2023-10-03_06-35-57_Screenshot](https://discourse.nixos.org/uploads/default/original/2X/e/ef7a0fd86662c887fac3d6d8873a76a3b4b78985.png)

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:

```auto
{ 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";
            }
          ];
        };
      };
}

```

---

<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: [October 3, 2023, 8:28pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/2 "2023-10-03T20:28:16Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![gemstraam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gemstraam/32/7361_2.png) [@gemstraam](https://discourse.nixos.org/u/gemstraam)
#### Post date: [October 4, 2023, 5:29pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/3 "2023-10-04T17:29:17Z")

</div>

Thank you Peter! Will check it out …

---

<div class="post-metadata">

### Author: ![Nerdenco](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/n/8491ac/32.png) [@Nerdenco](https://discourse.nixos.org/u/Nerdenco)
#### Post date: [March 18, 2024, 2:00pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/4 "2024-03-18T14:00:57Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![gemstraam](https://discourse.nixos.org/user_avatar/discourse.nixos.org/gemstraam/32/7361_2.png) [@gemstraam](https://discourse.nixos.org/u/gemstraam)
#### Post date: [March 18, 2024, 5:12pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/5 "2024-03-18T17:12:26Z")

</div>

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 😉

```auto
{ 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 …

---

<div class="post-metadata">

### Author: ![Nerdenco](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/n/8491ac/32.png) [@Nerdenco](https://discourse.nixos.org/u/Nerdenco)
#### Post date: [March 20, 2024, 2:19pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/6 "2024-03-20T14:19:46Z")

</div>

Thank you both @gemstraam and @peterhoeg 🙂 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:

```nix
{ 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!

---

<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, 2024, 12:54pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/7 "2024-03-21T12:54:11Z")

</div>

> 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:

[https://help.brother-usa.com/app/answers/detail/a\_id/164936/~/how-to-create-a-brother-ppd-file-for-installation---linux](https://help.brother-usa.com/app/answers/detail/a_id/164936/~/how-to-create-a-brother-ppd-file-for-installation---linux)

In order to decompress the file you will need this:

> <https://github.com/NixOS/nixpkgs/pull/297688>
>
> \## Description of changes
> 
> Useful if one needs to decompress a .PPD file from a …printer driver.
> 
> \## Things done
> 
> 
> 
> \- Built on platform(s)
> - \[X\] x86\_64-linux
> - \[\] aarch64-linux
> - \[\] x86\_64-darwin
> - \[\] aarch64-darwin
> \- For non-Linux: Is sandboxing enabled in \`nix.conf\`? (See \[Nix manual\](https://nixos.org/manual/nix/stable/command-ref/conf-file.html))
> - \[\] \`sandbox = relaxed\`
> - \[\] \`sandbox = true\`
> \- \[\] Tested, as applicable:
> - \[NixOS test(s)\](https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests) (look inside \[nixos/tests\](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests))
> - and/or \[package tests\](https://nixos.org/manual/nixpkgs/unstable/#sec-package-tests)
> - or, for functions and "core" functionality, tests in \[lib/tests\](https://github.com/NixOS/nixpkgs/blob/master/lib/tests) or \[pkgs/test\](https://github.com/NixOS/nixpkgs/blob/master/pkgs/test)
> - made sure NixOS tests are \[linked\](https://nixos.org/manual/nixpkgs/unstable/#ssec-nixos-tests-linking) to the relevant packages
> \- \[\] Tested compilation of all packages that depend on this change using \`nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"\`. Note: all changes have to be committed, also see \[nixpkgs-review usage\](https://github.com/Mic92/nixpkgs-review#usage)
> \- \[X\] Tested basic functionality of all binary files (usually in \`./result/bin/\`)
> \- \[24.05 Release Notes\](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2405.section.md) (or backporting \[23.05\](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2305.section.md) and \[23.11\](https://github.com/NixOS/nixpkgs/blob/master/nixos/doc/manual/release-notes/rl-2311.section.md) Release notes)
> - \[\] (Package updates) Added a release notes entry if the change is major or breaking
> - \[\] (Module updates) Added a release notes entry if the change is significant
> - \[\] (Module addition) Added a release notes entry if adding a new NixOS module
> \- \[X\] Fits \[CONTRIBUTING.md\](https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md).
> 
> \<!--
> To help with the large amounts of pull requests, we would appreciate your
> reviews of other pull requests, especially simple package updates. Just leave a
> comment describing what you have tested in the relevant package/service.
> Reviewing helps to reduce the average time-to-merge for everyone.
> Thanks a lot if you do!
> 
> List of open PRs: https://github.com/NixOS/nixpkgs/pulls
> Reviewing guidelines: https://nixos.org/manual/nixpkgs/unstable/#chap-reviewing-contributions
> \--\>
> 
> \---
> 
> Add a :+1: \[reaction\] to \[pull requests you find important\].
> 
> \[reaction\]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
> \[pull requests you find important\]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc

---

<div class="post-metadata">

### Author: ![Nerdenco](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/n/8491ac/32.png) [@Nerdenco](https://discourse.nixos.org/u/Nerdenco)
#### Post date: [March 22, 2024, 2:03pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/8 "2024-03-22T14:03:45Z")

</div>

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

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`.

---

<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 22, 2024, 3:03pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/9 "2024-03-22T15:03:41Z")

</div>

```sh
7zz x name-of-exe

```

No windows needed!

---

<div class="post-metadata">

### Author: ![Nerdenco](https://discourse.nixos.org/letter_avatar_proxy/v4/letter/n/8491ac/32.png) [@Nerdenco](https://discourse.nixos.org/u/Nerdenco)
#### Post date: [March 22, 2024, 6:23pm UTC](https://discourse.nixos.org/t/declarative-printer-setup-missing-driver/33777/10 "2024-03-22T18:23:12Z")

</div>

And… of course there’s a way 😄 Thanks!
