Printing: Difference between revisions
imported>MasseGuillaume mNo edit summary |
imported>HLandau No edit summary |
||
| Line 1: | Line 1: | ||
= Basic configuration = | =Basic configuration= | ||
Add to <code>configuration.nix</code>: | <ol><li>Add to <code>/etc/nixos/configuration.nix</code>: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.printing.enable = true; | { | ||
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: | |||
* | * <tt>pkgs.gutenprint</tt> — Drivers for many different printers from many different vendors. | ||
* | * <tt>pkgs.gutenprintBin</tt> — Additional, binary-only drivers for some printers. | ||
* <tt>pkgs.hplip</tt> — Drivers for HP printers. | |||
* <tt>pkgs.splix</tt> — Drivers for printers supporting SPL (Samsung Printer Language). | |||
* Some printers might be supported by built-in CUPS drivers. | |||
* [https://nixos.org/nixos/packages.html Search for other printer drivers in the NixOS package directory.] | |||
(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.</p> | |||
<p>You may need to authenticate when you add the printer. Search the web for e.g. “cups add printer” for further information.</p></li></ol> | |||
= | =Setting up shared printers= | ||
==Server== | |||
= | <ol> | ||
<li>Follow the steps in [[#basic-configuration|Basic Configuration]], but check “Share This Printer” when adding it to CUPS. If you have already added the printer to CUPS, reconfigure it to make it a shared printer.</li> | |||
<li>You should probably check that printing works locally at this point.</li> | |||
<li>Amend <tt>/etc/nixos/configuration.nix</tt>: | |||
<syntaxhighlight lang="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 ]; | |||
... | |||
} | |||
</syntaxhighlight></li> | |||
<li>Rebuild: <syntaxhighlight lang="console">$ sudo nixos-rebuild switch</syntaxhighlight></li></ol> | |||
</syntaxhighlight> | |||
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. | 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. | ||
{{outdated|Needs checking to rectify uncertainty in instructions}} | |||
== Client (Linux) == | |||
If you enabled {{nixos:option|services.avahi.publish.userServices}} in the server configuration, enabling printing and avahi on the client should be sufficient for the printer to be detected: | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
{ | |||
... | |||
services.printing.enable = true; | |||
services.avahi.enable = true; | |||
services.avahi.nssmdns = true; | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Alternately, the printer can be added to the client's CUPS daemon by navigating to <tt>http://localhost:631/</tt> in a web browser and adding the remote printer. | |||
</ | |||
== | ==See also== | ||
* [https://github.com/NixOS/nixpkgs/issues/13901 How to properly setup a shared (home) printer? #13901] | * [https://github.com/NixOS/nixpkgs/issues/13901 How to properly setup a shared (home) printer? #13901] | ||
* [https://wiki.archlinux.org/index.php/CUPS/Printer_sharing Arch wiki | * [https://wiki.archlinux.org/index.php/CUPS/Printer_sharing Printer sharing (Arch Linux wiki)] | ||
* [https://github.com/NixOS/nixpkgs/issues/23993 Little Printing/CUPS Documentation for Configuration as a Print Server #23993] | * [https://github.com/NixOS/nixpkgs/issues/23993 Little Printing/CUPS Documentation for Configuration as a Print Server #23993] | ||
* [https://web.archive.org/web/20160829175522/https://nixos.org/wiki/Printers Old wiki page] | * [https://web.archive.org/web/20160829175522/https://nixos.org/wiki/Printers Old wiki page] | ||