Printing: Difference between revisions

imported>Onny
First work on major cleanup of the page
imported>Onny
Further cleanup
Line 11: Line 11:
== Usage ==
== Usage ==


After enabling the printing service you'll be able to configure and add network printers via http://localhost:631.
After enabling the printing service you'll be able to configure and add network printers via http://localhost:631. You may need to authenticate with your local user when you add the printer.


Depending on your desktop environment, there are several graphical tools available which will connect to this backend service and allow you a more convenient printer management.
Depending on your desktop environment, there are several graphical tools available which will connect to this backend service and allow you a more convenient printer management, for example <code>system-config-printer</code>.


== Configuration ==
== Configuration ==


=== Enable autodiscovery of network printers ===
=== Adding printers ===


Most printers manufactured after 2013 support the [https://www.pwg.org/ipp/everywhere.html IPP Everywhere] protocol, i.e. printing without installing drivers. This is notably the case of all WiFi printers marketed as Apple-compatible ([https://support.apple.com/en-ca/HT201311 list]).
Beside manually adding printers with client tools, it is possible to permanently add printers to your system configuration:


To detect these printers, add the following to your system configuration:
<syntaxhighlight lang="nix">
{{file|/etc/nixos/configuration.nix|nix|<nowiki>
services.printing.enable = true;
services.avahi = {
</syntaxhighlight>
  enable = true;
  nssmdns = true;
  openFirewall = true;
}
</nowiki>}}
 
Discovery is done via the opened UDP port <code>5353</code>. Printers should get automatically detected and visible in your printer configuration client.


=== Driver-based printing ===
Some local or network printers might need additional drivers. You can add them using the <code>drivers</code> option
<ol><li>Add to <code>/etc/nixos/configuration.nix</code>:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{
services.printing.drivers = [ YOUR_DRIVER ];
  ...
  services.printing.enable = true;
  services.printing.drivers = [ YOUR_DRIVER ];
  ...
}
</syntaxhighlight>
</syntaxhighlight>
where <code>YOUR_DRIVER</code> is the driver package appropriate for your printer. Commonly used driver packages include:
where <code>YOUR_DRIVER</code> is the driver package appropriate for your printer. Commonly used driver packages include:


Line 58: Line 46:
* Search for other printer drivers in the NixOS package directory: the official list of packages is [https://search.nixos.org/packages here] but does not list unfree packages (which is the case of many printer drivers). To list unfree packages, see [[FAQ#How_can_I_install_a_proprietary_or_unfree_package.3F|The appropriate FAQ entry for installing unfree packages.]]
* Search for other printer drivers in the NixOS package directory: the official list of packages is [https://search.nixos.org/packages here] but does not list unfree packages (which is the case of many printer drivers). To list unfree packages, see [[FAQ#How_can_I_install_a_proprietary_or_unfree_package.3F|The appropriate FAQ entry for installing unfree packages.]]


(Add the driver to {{nixos:option|services.printing.drivers}}, '''not''' {{nixos:option|environment.systemPackages}}.)
Add the driver to {{nixos:option|services.printing.drivers}}, '''not''' {{nixos:option|environment.systemPackages}}.
<li>Rebuild: <syntaxHighlight lang="console">$ sudo nixos-rebuild switch</syntaxHighlight>
CUPS will be started automatically.</li>
<li><p>Navigate to <tt>http://localhost:631/</tt> in a web browser to configure printers. Alternatively, some desktop environments may provide GUI interfaces for adding printers, for example <code>system-config-printer</code>.</p>


<p>You may need to authenticate when you add the printer. Search the web for e.g. &#8220;cups add printer&#8221; for further information.</p></li></ol>
=== Enable autodiscovery of network printers ===
 
Most printers manufactured after 2013 support the [https://www.pwg.org/ipp/everywhere.html IPP Everywhere] protocol, i.e. printing without installing drivers. This is notably the case of all WiFi printers marketed as Apple-compatible ([https://support.apple.com/en-ca/HT201311 list]).
 
To detect these printers, add the following to your system configuration:
<syntaxhighlight lang="nix">
services.avahi = {
  enable = true;
  nssmdns = true;
  openFirewall = true;
}
</syntaxhighlight>
 
Discovery is done via the opened UDP port <code>5353</code>. Printers should get automatically detected and visible in your printer configuration client.


==== With a raw PPD ====
==== With a raw PPD ====
Line 124: Line 121:


For debugging purpose, it may be interesting to note that the data folder used by cups (containing the drivers and more) can be obtained by looking in the environment <code>$CUPS_DATADIR</code> (the contents of <code>$out/share/cups/</code> contained in your drivers are linked in this folder).
For debugging purpose, it may be interesting to note that the data folder used by cups (containing the drivers and more) can be obtained by looking in the environment <code>$CUPS_DATADIR</code> (the contents of <code>$out/share/cups/</code> contained in your drivers are linked in this folder).
===== Networked printers =====
In some cases (e.g.: the Brother HL-3170CDW), you don't even need drivers or a PPD file. Simply open up the CUPS dashboard, add a printer at <code>ipp://your-printer-ip</code>, and make sure to select the "IPP Everywhere" driver.


==Setting up shared printers==
==Setting up shared printers==