Skip to content

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.

  1. 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.

  2. Choose the driver

    The driver package provides one PPD file per model: its path, relative to share/cups/model/, becomes model.

    Fenêtre de terminal
    ls $(nix build --no-link --print-out-paths nixpkgs#epson-escpr2)/share/cups/model/*/ | grep 8550
  3. 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 add the new file, then just clean.

  4. 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.

  5. Deploy

    just apply hcs, then the workstations. CUPS creates the queue at startup.

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.

CUPS starts on demand: lpstat -v starts it and lists the queues.

In its own zone, mDNS discovery adds it too. Both queues print.

Removing it from the list does not delete its queue: sudo lpadmin -x Epson-ET-8550 on each workstation.