Printing: Difference between revisions

imported>Onny
Further cleanup
imported>Onny
Further cleanup
Line 19: Line 19:
=== Adding printers ===
=== Adding printers ===


Beside manually adding printers with client tools, it is possible to permanently add printers to your system configuration. The following example adds the printer <code>Dell_1250c</code> via local USB address by also defining which driver to use using the <code>model</code> option.
Beside manually adding printers with client tools, it is possible to permanently add printers to your system configuration. The following example configures a network printer called <code>Dell_1250c</code> to your local system, reachable via IPP at <code>http://192.168.178.2:631/printers/Dell_1250c</code>
 
<syntaxhighlight lang="nix">
hardware.printers = {
  ensurePrinters = [
    {
      name = "Dell_1250c";
      location = "Home";
      deviceUri = "http://192.168.178.2:631/printers/Dell_1250c";
      model = "drv:///sample.drv/generic.ppd";
      ppdOptions = {
        PageSize = "A4";
      };
    }
  ];
  ensureDefaultPrinter = "Dell_1250c";
};
</syntaxhighlight>
 
To add a local printer, conntected via USB, change the <code>deviceUri</code> to a USB address and optionally define which driver to use by adding the <code>model</code> option.


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 34: Line 53:
     }
     }
   ];
   ];
  ensureDefaultPrinter = "Dell_1250c";
};
};
</syntaxhighlight>
</syntaxhighlight>
Line 58: Line 76:


Search for other printer drivers in the NixOS package directory: the official list of packages is [https://search.nixos.org/packages here]. Add the driver to {{nixos:option|services.printing.drivers}}, '''not''' {{nixos:option|environment.systemPackages}}.
Search for other printer drivers in the NixOS package directory: the official list of packages is [https://search.nixos.org/packages here]. Add the driver to {{nixos:option|services.printing.drivers}}, '''not''' {{nixos:option|environment.systemPackages}}.
The following example configures a network printer to your local system, reachable via IPP at <code>http://192.168.178.2:631/printers/Dell_1250c</code>
<syntaxhighlight lang="nix">
hardware.printers = {
  ensurePrinters = [
    {
      name = "Dell_1250c";
      location = "Home";
      deviceUri = "http://192.168.178.2:631/printers/Dell_1250c";
      model = "drv:///sample.drv/generic.ppd";
      ppdOptions = {
        PageSize = "A4";
      };
    }
  ];
};
</syntaxhighlight>


=== Enable autodiscovery of network printers ===
=== Enable autodiscovery of network printers ===