Printing: Difference between revisions

imported>Makefu
initial batch of nixos-users
 
imported>Fadenb
m Syntax highlighting
Line 3: Line 3:
Add to <code>configuration.nix</code>:
Add to <code>configuration.nix</code>:


<pre>services.printing.enable = true;
<syntaxhighlight lang="nix">
services.printing.drivers = [ YOUR_DRIVER ];</pre>
services.printing.enable = true;
Replace <code>YOUR_DRIVER</code> with the driver of your printer. The driver is a regular derivation but should be added to <code>services.printing.drivers</code>, ''not'' <code>environment.systemPackages</code>. [https://nixos.org/nixos/packages.html Search] for eg. &quot;print driver&quot;.
services.printing.drivers = [ YOUR_DRIVER ];
</syntaxhighlight>
Replace <code>YOUR_DRIVER</code> with the driver of your printer. The driver is a regular derivation but should be added to <syntaxhighlight lang="nix" inline>services.printing.drivers</syntaxhighlight>, ''not'' <syntaxhighlight lang="nix" inline>environment.systemPackages</syntaxhighlight>. [https://nixos.org/nixos/packages.html Search] for eg. "print driver".


* Some printers might be supported by the built-in CUPS drivers
* Some printers might be supported by the built-in CUPS drivers
Line 24: Line 26:
Add to <code>configuration.nix</code>
Add to <code>configuration.nix</code>


<pre># Enable automatic discovery of the printer (from other linux systems with avahi running)
<syntaxhighlight lang="nix">
# Enable automatic discovery of the printer (from other linux systems with avahi running)
services.avahi.enable = true;
services.avahi.enable = true;
services.avahi.publish.enable = true;
services.avahi.publish.enable = true;
Line 30: Line 33:


services.printing.browsing = true;
services.printing.browsing = true;
services.printing.listenAddresses = [ &quot;*:631&quot; ]; # Not 100% sure this is needed and you might want to restrict to the local network
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
services.printing.defaultShared = true; # If you want


networking.firewall.allowedUDPPorts = [ 631 ];
networking.firewall.allowedUDPPorts = [ 631 ];
networking.firewall.allowedTCPPorts = [ 631 ];</pre>
networking.firewall.allowedTCPPorts = [ 631 ];
</syntaxhighlight>
and <code>nixos-rebuild switch</code>.
and <code>nixos-rebuild switch</code>.


Note: I ''think'' I had to check &quot;Share printers connected to this system&quot; and &quot;Allow printing from the internet&quot; 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.


== Client (linux) ==
== Client (linux) ==


If you enabled avahi user services in the server config it should be enough to turn on avahi on the client: <code>services.avahi.enable = true</code>. The printer should be found automatically (at least in the gnome print dialog).
If you enabled avahi user services in the server config it should be enough to turn on avahi on the client: <syntaxhighlight lang="nix" inline>services.avahi.enable = true</syntaxhighlight>. The printer should be found automatically (at least in the gnome print dialog).


Otherwise CUPS (<code>services.printing</code>) 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 <code>http://HOSTNAME:631/printers/QUEUE_NAME</code>, where QUEUE_NAME is the name you gave the printer at the server.
Otherwise CUPS (<code>services.printing</code>) 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 <code>http://HOSTNAME:631/printers/QUEUE_NAME</code>, where QUEUE_NAME is the name you gave the printer at the server.