Network printer config sometimes breaks after reboot

From what I can tell, I was bit by some bug in the cupsd package (possibly this one, but I’m not sure), and while there’s a temporary workaround described in “Printer connections default to /dev/null in 25.05”, it doesn’t survive after running nixos-rebuild switch and rebooting sometimes doesn’t survive a reboot and gets overwritten by a broken one.

Here’s what a working /etc/printer.conf on my system (generated via the aforementioned workaround) looks like:

# Printer configuration file for CUPS v2.4.11
# Written by cupsd
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
NextPrinterId 17
<Printer EPSON_ET_3850_Series>
PrinterId 16
UUID urn:uuid:cf7affeb-0fdb-3a75-4569-e3340155554a
Info EPSON_ET_3850_Series
Location 
MakeModel Printer - IPP Everywhere
DeviceURI ipp://EPSON446CC1.local:631/ipp/print
State Idle
StateTime 1751501648
ConfigTime 1751501711
Type 36892
Accepting Yes
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
Option cups-browsed true
</Printer>

Here’s what a broken one (one that leads to printer dialogs describing it as “Rejecting Jobs”) looks like:

# Printer configuration file for CUPS v2.4.11
# Written by cupsd
# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING
NextPrinterId 18
<Printer EPSON_ET_3850_Series>
PrinterId 17
UUID urn:uuid:fbdbd260-a35a-3cca-752c-c4ecaa6d7353
Info EPSON_ET_3850_Series
DeviceURI file:///dev/null
State Stopped
StateTime 1751502584
ConfigTime 1751502584
Type 4
Accepting No
Shared No
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
OpPolicy default
ErrorPolicy stop-printer
Option cups-browsed true
</Printer>

It’s as if CUPS’s auto-configuration is flaky somehow.

As an attempt at a workaround, I tried adding this to my configuration.nix, though I don’t know yet if it will it does not consistently work:

hardware.printers = {
    ensureDefaultPrinter = "EPSON_ET_3850_Series";
    ensurePrinters = [
      {
        deviceUri = "ipp://EPSON446CC1.local:631/ipp/print";
        location = "home";
        name = "EPSON_ET_3850_Series";
        model = "everywhere";
      }
    ];
  };

When it didn’t work, I saw that I got the following errors after running sudo nixos-rebuild switch:

warning: the following units failed: ensure-printers.service
× ensure-printers.service - Ensure NixOS-configured CUPS printers
     Loaded: loaded (/etc/systemd/system/ensure-printers.service; enabled; preset: ignored)
     Active: failed (Result: exit-code) since Wed 2025-07-02 21:21:42 EDT; 294ms ago
 Invocation: 971db208198144299b3d5ff572b106a5
    Process: 3097 ExecStart=/nix/store/sd443ycrs0vz6iij6v7s0m14is0z77g3-unit-script-ensure-printers-start/bin/ensure-printers-start (code=exited, status=1/FAILURE)
   Main PID: 3097 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
         IO: 0B read, 0B written
   Mem peak: 2.2M
        CPU: 18ms

Jul 02 21:21:41 nixos systemd[1]: Starting Ensure NixOS-configured CUPS printers...
Jul 02 21:21:42 nixos ensure-printers-start[3098]: lpadmin: Unable to connect to EPSON446CC1.local:631: System error
Jul 02 21:21:42 nixos systemd[1]: ensure-printers.service: Main process exited, code=exited, status=1/FAILURE
Jul 02 21:21:42 nixos systemd[1]: ensure-printers.service: Failed with result 'exit-code'.
Jul 02 21:21:42 nixos systemd[1]: Failed to start Ensure NixOS-configured CUPS printers.
warning: error(s) occurred while switching to the new configuration

Is there a better, more consistent workaround?

Or better yet, is there an actual solution somewhere?

I found what so far seems to be a two consistent workarounds, which I described in the latter part of a Reddit post.