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>: | ||
< | <syntaxhighlight lang="nix"> | ||
services.printing.drivers = [ YOUR_DRIVER ];</ | 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 < | 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> | ||
< | <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 = [ | 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 ];</ | networking.firewall.allowedTCPPorts = [ 631 ]; | ||
</syntaxhighlight> | |||
and <code>nixos-rebuild switch</code>. | and <code>nixos-rebuild switch</code>. | ||
Note: I ''think'' I had to check | 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: < | 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. | ||