Sharing a network printer
A printer discovered automatically (mDNS) only appears in its own zone. Once declared, it is installed on every workstation in the fleet, whatever its zone: printing goes through the VPN routes.
Example: an Epson ET-8550 in the maison zone, at 10.0.4.10.
-
Pin its address
An address from the dynamic DHCP range may change. Declare the printer in its zone’s non-NixOS devices (MAC address read from its panel or web interface), then
just clean. -
Choose the driver
The driver package provides one PPD file per model: its path, relative to
share/cups/model/, becomesmodel.Fenêtre de terminal ls $(nix build --no-link --print-out-paths nixpkgs#epson-escpr2)/share/cups/model/*/ | grep 8550 -
Declare the printer
usr/modules/is imported on every host: one file is enough for the whole fleet. The option only acts on hosts where printing is enabled (workstations).usr/modules/printers.nix { pkgs, ... }:{darkone.service.printing.networkPrinters = [{name = "Epson-ET-8550";description = "Epson ET-8550";location = "Bureau";uri = "ipp://10.0.4.10/ipp/print";driver = pkgs.epson-escpr2;model = "epson-inkjet-printer-escpr2/Epson-ET-8550_Series-epson-escpr2-en.ppd";}];}git addthe new file, thenjust clean. -
Open it to personal devices
Zone workstations and admin workstations already reach it. A device connected to the VPN with its own identity needs a rule on port 631, in the same file (it only acts on the HCS):
usr/modules/printers.nix darkone.service.headscale.policy = {extraHosts.printer-maison = "10.0.4.10/32";extraAcls = [{action = "accept";src = [ "autogroup:member" ];dst = [ "printer-maison:631" ];}];};Option details: Adapting the access policy.
-
Deploy
just apply hcs, then the workstations. CUPS creates the queue at startup.
Why not model = "everywhere"?
Section titled “Why not model = "everywhere"?”No driver, but CUPS then queries the printer on every startup: switched off
or out of reach (laptop on the move), it makes cups.service fail.
A PPD is static.
The queue does not appear
Section titled “The queue does not appear”CUPS starts on demand: lpstat -v starts it and lists the queues.
The printer appears twice
Section titled “The printer appears twice”In its own zone, mDNS discovery adds it too. Both queues print.
Removing a printer
Section titled “Removing a printer”Removing it from the list does not delete its queue: sudo lpadmin -x Epson-ET-8550
on each workstation.