Printing

From NixOS Wiki
Revision as of 08:12, 30 August 2017 by imported>Joepie91

Basic configuration

Add to configuration.nix:

services.printing.enable = true;
services.printing.drivers = [ YOUR_DRIVER ];

Replace YOUR_DRIVER with the driver of your printer (eg. pkgs.gutenprintBin). The driver is a regular derivation but should be added to services.printing.drivers, not environment.systemPackages. Search for eg. "print driver".

  • Some printers might be supported by the built-in CUPS drivers
  • HP: pkgs.hplip or pkgs.hplipWithPlugin depending on your exact model: Find your model and "continue". Then search for "Driver plug-in" in the page.

Then nixos-rebuild switch. This install and starts CUPS.

Go to http://localhost:631 to add the printer. Note that you need to authenticate as root (or yourself if you have sudo access) when you add the printer. Search the web for eg. "cups add printer" for further help.

Setup a shared printer

Server

Follow the steps in basic configuration but make sure to check "Share This Printer" when adding the printer.

It's probably a good idea to check that printing work locally at the server at this point.

Add to configuration.nix

# Enable automatic discovery of the printer (from other linux systems with avahi running)
services.avahi.enable = true;
services.avahi.publish.enable = true;
services.avahi.publish.userServices = true;

services.printing.browsing = true;
services.printing.listenAddresses = [ "*:631" ]; # Not 100% sure this is needed and you might want to restrict to the local network
services.printing.defaultShared = true; # If you want

networking.firewall.allowedUDPPorts = [ 631 ];
networking.firewall.allowedTCPPorts = [ 631 ];

and nixos-rebuild switch.

Note: I think I had to check "Share printers connected to this system" and "Allow printing from the internet" at http://192.168.11.9:631/admin but I'm not sure.

Client (linux)

If you enabled avahi user services in the server config it should be enough to turn on avahi on the client: services.avahi.enable = true. The printer should be found automatically (at least in the gnome print dialog).

Otherwise CUPS (services.printing) should be enabled on the client too and a new network printer should be added to the local CUPS instance (http://localhost:631). Despite what the CUPS interface tell you the url scheme is http://HOSTNAME:631/printers/QUEUE_NAME, where QUEUE_NAME is the name you gave the printer at the server.

NB: https might not work due to missing certificates.

Refer to eg. https://wiki.archlinux.org/index.php/CUPS/Printer_sharing for further info.

Client (windows)

See https://wiki.archlinux.org/index.php/CUPS/Printer_sharing#Sharing_via_IPP for now.

Sources