share printers

This commit is contained in:
Daniel Langbein 2023-10-12 17:57:08 +02:00
parent 3b775c9387
commit ece1c7d60b
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002

View File

@ -1,20 +1,56 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
# Printing with IPP everywhere capable printers # Printing with IPP everywhere capable printers
# https://nixos.wiki/wiki/Printing # https://nixos.wiki/wiki/Printing
# Share printer via AirPrint
# https://project-insanity.org/2021/10/12/share-printer-via-airprint-with-nixos/
# After following these steps, my manually added Lexmark E460dn was instantly found on an Apple iPad.
# Enable CUPS to print documents. # When adding the Lexmark E460dn printer (via GNOME settings or directly on the CUPS web interface),
services.printing.enable = true; # it is not found lateron. Discovery through the detected URL does not work.
# HP and Lexmark drivers # Instead, I added it manually.
services.printing.drivers = [ pkgs.hplip pkgs.postscript-lexmark ]; # - When adding a printer, select `AppSocket/HP JetDirect` as type.
services.avahi.enable = true; # - Then fill in the IP of the printer, e.g. `socket://192.168.178.107:9100`
services.avahi.nssmdns = true; # Reference: https://infoserve.lexmark.com/ids/ifc/ids_topic.aspx?root=kb20220119195146366&gid=v54804876&id=v54804875&topic=HO2475&productCode=Lexmark_T642&loc=en_CA
# WiFi printers
services.avahi.openFirewall = true; networking.firewall = {
allowedTCPPorts = [ 631 ];
allowedUDPPorts = [ 631 ];
};
services.printing = {
# Enable CUPS to print documents.
enable = true;
# HP and Lexmark drivers
drivers = [ pkgs.hplip pkgs.postscript-lexmark ];
# Specifies whether shared printers are advertised.
browsing = true;
defaultShared = true;
listenAddresses = [ "*:631" ];
allowFrom = [ "all" ];
extraConf = ''
DefaultPaperSize A4
'';
};
services.avahi = {
enable = true;
# Whether to enable the mDNS NSS (Name Service Switch) plug-in.
# Enabling it allows applications to resolve names in the .local domain by transparently querying the Avahi daemon.
# -> Discover network printers.
nssmdns = true;
# Network printers
openFirewall = true;
publish = {
enable = true;
userServices = true;
};
};
# Scanning # Scanning
# https://nixos.wiki/wiki/Scanners # https://nixos.wiki/wiki/Scanners
# https://unix.stackexchange.com/questions/518687/how-do-i-set-up-scanning-from-an-hp-officejet-pro-on-nixos/518688 # HP OfficeJet scanning
# https://unix.stackexchange.com/questions/518687/how-do-i-set-up-scanning-from-an-hp-officejet-pro-on-nixos/518688
hardware.sane = { hardware.sane = {
enable = true; enable = true;
# Optionally, add pkgs.sane-airscan for AirScan. # Optionally, add pkgs.sane-airscan for AirScan.