diff --git a/modules/print-and-scan.nix b/modules/print-and-scan.nix index a8af7bf..ab81d44 100644 --- a/modules/print-and-scan.nix +++ b/modules/print-and-scan.nix @@ -1,20 +1,56 @@ { config, pkgs, ... }: { # 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. - services.printing.enable = true; - # HP and Lexmark drivers - services.printing.drivers = [ pkgs.hplip pkgs.postscript-lexmark ]; - services.avahi.enable = true; - services.avahi.nssmdns = true; - # WiFi printers - services.avahi.openFirewall = true; + # When adding the Lexmark E460dn printer (via GNOME settings or directly on the CUPS web interface), + # it is not found lateron. Discovery through the detected URL does not work. + # Instead, I added it manually. + # - When adding a printer, select `AppSocket/HP JetDirect` as type. + # - Then fill in the IP of the printer, e.g. `socket://192.168.178.107:9100` + # Reference: https://infoserve.lexmark.com/ids/ifc/ids_topic.aspx?root=kb20220119195146366&gid=v54804876&id=v54804875&topic=HO2475&productCode=Lexmark_T642&loc=en_CA + + 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 - # 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 + # https://nixos.wiki/wiki/Scanners + # 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 = { enable = true; # Optionally, add pkgs.sane-airscan for AirScan.