# SOLVED Auto discovered network printer

**URL:** https://discourse.nixosstag.fcio.net/t/solved-auto-discovered-network-printer/67733
**Category:** Help
**Created:** [August 7, 2025, 8:27pm UTC](https://discourse.nixosstag.fcio.net/t/solved-auto-discovered-network-printer/67733 "2025-08-07T20:27:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![yurimodin](https://discourse.nixosstag.fcio.net/letter_avatar_proxy/v4/letter/y/d9b06d/32.png) [@yurimodin](https://discourse.nixosstag.fcio.net/u/yurimodin)
#### Post date: [August 7, 2025, 8:27pm UTC](https://discourse.nixosstag.fcio.net/t/solved-auto-discovered-network-printer/67733/1 "2025-08-07T20:27:01Z")

</div>

been fighting this for 2 days. All auto discovered ipp printers are pointing to /dev/null instead of their IP.

Between [NixOS Search](https://search.nixos.org/options?channel=25.05) and Google I have tried everything I can think of. Has anyone seen this?

`services.printing = {`

`enable = true;`

`cups-pdf.enable = true;`

`browsed.enable = true;`

`browsedConf = ''`

`CreateIPPPrinterQueues All`

`'';`

`drivers = [`

`pkgs.gutenprint`

`pkgs.hplip`

`pkgs.cnijfilter2`

`pkgs.hplipWithPlugin`

`];`

`};`

`services.system-config-printer.enable = true;`

`#services.ipp-usb.enable = true;`

`services.avahi = {`

`enable = true;`

`nssmdns4 = true;`

`openFirewall = true;`

`};`

---

<div class="post-metadata">

### Author: ![yurimodin](https://discourse.nixosstag.fcio.net/letter_avatar_proxy/v4/letter/y/d9b06d/32.png) [@yurimodin](https://discourse.nixosstag.fcio.net/u/yurimodin)
#### Post date: [August 8, 2025, 6:46pm UTC](https://discourse.nixosstag.fcio.net/t/solved-auto-discovered-network-printer/67733/2 "2025-08-08T18:46:12Z")

</div>

SOLVED, this isn’t the cleanest but it works…got together with Google Gemini and we created a systemd daemon that finds all printers at boot and then adds them automatically the way its supposed to by default.

> `# Enable CUPS to print documents.`
> 
> `services.printing = {`
> 
> `enable = true;`
> 
> `cups-pdf.enable = true;`
> 
> `browsed.enable = false;`
> 
> `browsedConf = ''`
> 
> `CreateIPPPrinterQueues None`
> 
> `CreateRemoteRawPrinterQueues no`
> 
> `'';`
> 
> `drivers = [`
> 
> `pkgs.gutenprint`
> 
> `pkgs.hplip`
> 
> `pkgs.cnijfilter2`
> 
> `pkgs.hplipWithPlugin`
> 
> `];`
> 
> `};`
> 
> `services.avahi.enable = true;`
> 
> `services.system-config-printer.enable = true;`
> 
> `systemd.services.add-network-printers = {`
> 
> `description = "Dynamically add available network printers to CUPS";`
> 
> `script = ''`
> 
> `${pkgs.avahi}/bin/avahi-browse -rtp _ipp._tcp | while read -r line; do`
> 
> `if [["$line" == =*]]; then`
> 
> `IP_ADDRESS=$(${pkgs.gawk}/bin/awk -F';' '{print $8}' <<< "$line")`
> 
> `RAW_NAME=$(${pkgs.gawk}/bin/awk -F';' '{print $4}' <<< "$line")`
> 
> `if [["$IP_ADDRESS" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then`
> 
> `CLEAN_NAME=$(echo "$RAW_NAME" | ${pkgs.gnused}/bin/sed 's/\\032/ /g')`
> 
> `CLEAN_NAME=$(printf '%b\n' "$CLEAN_NAME")`
> 
> `LAST_OCTET=$(${pkgs.gawk}/bin/awk -F'.' '{print $4}' <<< "$IP_ADDRESS")`
> 
> `if [["$CLEAN_NAME" == *Color*]]; then`
> 
> `QUEUE_NAME="COLOR''${LAST_OCTET}"`
> 
> `else`
> 
> `QUEUE_NAME="BW''${LAST_OCTET}"`
> 
> `fi`
> 
> `DEVICE_URI="ipp://$IP_ADDRESS/ipp/print"`
> 
> `echo "Adding printer: $QUEUE_NAME at $DEVICE_URI"`
> 
> `${pkgs.cups}/bin/lpadmin -p "$QUEUE_NAME" -v "$DEVICE_URI" -m everywhere -E -o printer-is-shared=false`
> 
> `fi`
> 
> `fi`
> 
> `done`
> 
> `'';`
> 
> `after = ["network-online.target" "cups.service"];`
> 
> `wants = ["cups.service"];`
> 
> `wantedBy = ["multi-user.target"];`
> 
> `serviceConfig.Type = "oneshot";`
> 
> `};`
> 
> `systemd.services.create-user-pdf-links = {`
> 
> `description = "Create CUPS-PDF symlinks based on directories in /home";`
> 
> `wantedBy = ["multi-user.target"];`
> 
> `serviceConfig = {`
> 
> `Type = "oneshot";`
> 
> `User = "root";`
> 
> `# This provides all the necessary commands: basename, mkdir, ln, chown, etc.`
> 
> `path = [pkgs.coreutils];`
> 
> `};`
> 
> `script = ''`
> 
> `# Loop through every directory in /home`
> 
> `for homedir in /home/*; do`
> 
> `if [-d "$homedir"]; then`
> 
> `# Extract the username from the directory path`
> 
> `user=$(basename "$homedir")`
> 
> `# Define the paths`
> 
> `SPOOL_DIR="/var/spool/cups-pdf-pdf/users/$user"`
> 
> `LINK_NAME="$homedir/PDF"`
> 
> `# Create the spool directory as root`
> 
> `mkdir -p "$SPOOL_DIR"`
> 
> `# Set its ownership to the correct user`
> 
> `chown "$user":"users" "$SPOOL_DIR"`
> 
> `# Check if the symlink exists`
> 
> `if [! -e "$LINK_NAME"]; then`
> 
> `# Create the symlink as root`
> 
> `ln -s "$SPOOL_DIR" "$LINK_NAME"`
> 
> `# Set the ownership of the symlink itself (-h flag) to the correct user`
> 
> `chown -h "$user":"users" "$LINK_NAME"`
> 
> `fi`
> 
> `fi`
> 
> `done`
> 
> `'';`
> 
> `};`
