Lpr printing doesn't work

I’m trying to print using the lpr command. I’m only doing this because this is how emacs prints stuff. When using this lpr command in other distro’s, it just uses your default printer, and prints to it no issues.

In NixOS, my default printer is set and works fine (and lpr seems to recognize it), however I cannot print to it using lpr. I don’t know what config I need to add to get lpr working in this case, as I can’t find any mention of it anywhere.

I’m not quite sure what to do.

[1] greghab@nixGreg> lpstat -p -d
printer Brother-HL-L2380DW-series is idle.  enabled since Fri 29 May 2020 09:11:22 PM PDT
printer HP-Officejet-Pro-8600 is idle.  enabled since Sat 16 May 2020 08:30:17 PM PDT
system default destination: Brother-HL-L2380DW-series
greghab@nixGreg> lpr -P Brother-HL-L2380DW-series webinar.txt
lpr: can't connect to remote host ( Connection refused
[1] greghab@nixGreg> lpr  webinar.txt
lpr: can't connect to remote host ( Connection refused
[1] greghab@nixGreg> 

It’s as if lpr is not capable of connecting to the running cups server. Are you capable of printing using different interfaces? For example, via cups web interface “print test page”? Also, it might be helpful to see the options in your configuration.nix related to:

  • CUPS
  • Avahi
  • Networking
  • Firewall

Relevant configs are below:
I just disabled the firewall, but it didn’t help.
It’s a network printer that I connect to directly.

  # Or disable the firewall altogether.
   networking.firewall.enable = false;

   # Enable CUPS to print documents.
   services.printing.enable = true;
   services.avahi.enable = true;
   services.avahi.nssmdns = true;
   services.printing.drivers = [pkgs.brlaser pkgs.hplipWithPlugin pkgs.brgenml1lpr pkgs.brgenml1cupswrapper];

Printing a test page from cups web interface (localhost:631) does work fine.

Usually upstream is better at debugging these kind of stuff. Although NixOS is a weird beast, it’s not that different in certain senses compared to other distros. Specifically for cups, it’s configured on NixOS pretty much like on any other distro - using /etc/cups. They give support apparently at https://lists.cups.org/mailman/listinfo .

Will look into this. Thanks!