Brother DCP-L2530DW Network Scanner on NixOS (brscan4 driver issue)

Despite extensive troubleshooting, I’m unable to get my Brother DCP-L2530DW network scanner (IP: 192.168.0.139) working on NixOS. The core issue appears to be that the sane-backends package on my system is not correctly configured to find the brscan4 driver (libsane-brother4.so.1).

** Input file **

My nixos input file look like:

# nixos/modules/services/printing.nix
{
  lib,
  pkgs,
  ...
}: {
  ##############################################################################
  # System-wide CUPS setup with a fixed IPP queue for Brother DCP-L2530DW
  ##############################################################################
  services.printing = {
    enable = true;
    webInterface = true; # CUPS UI: http://localhost:631
    drivers = with pkgs; [
      gutenprint # generic drivers
      brlaser # Brother open driver (backup)
    ];
    browsed.enable = false; # we use a fixed queue, not autodiscovery
  };

  # mDNS/Avahi optional but harmless
  services.avahi = {
    enable = true;
    nssmdns4 = true;
    openFirewall = true;
  };

  ##############################################################################
  # Declarative printer queue
  ##############################################################################
  hardware.printers = {
    ensureDefaultPrinter = "Brother_DCP_L2530DW";
    ensurePrinters = [
      {
        name = "Brother_DCP_L2530DW";
        # ip of wifi at the first floor
        deviceUri = "ipp://192.168.0.139/ipp/print";
        model = "everywhere"; # IPP Everywhere (driverless)
        ppdOptions = {
          PageSize = "A4";
          Duplex = "DuplexNoTumble"; # long-edge duplex on A4
        };
      }
    ];
  };

  ##############################################################################
  # Ensure printers service waits for network and retries
  ##############################################################################
  systemd.services.ensure-printers = {
    after = ["NetworkManager-wait-online.service" "cups.service"];
    wants = ["NetworkManager-wait-online.service" "cups.service"];
    wantedBy = ["multi-user.target"];
    unitConfig = {
      StartLimitIntervalSec = "0";
    };
    serviceConfig = {
      Restart = "on-failure";
      RestartSec = "15s";
      SuccessExitStatus = [0];
    };
  };

  ##############################################################################
  # SANE (Scanner Access Now Easy) configuration for Brother DCP-L2530DW
  ##############################################################################
  hardware.sane = {
    enable = true;
    # Brother-specific SANE backend
    brscan4 = {
      enable = true;
      netDevices = {
        "Brother_DCP_L2530DW" = {
          model = "DCP-L2530DW";
          ip = "192.168.0.139";
        };
      };
    };
    # sane-airscan is a universal driver for modern network scanners (eSCL/WSD)
    # extraBackends = [ pkgs.sane-airscan ];
  };

  # sane-airscan uses mDNS (Avahi, already enabled) for discovery.
  # No extra firewall ports are typically needed if Avahi is correctly set up
  # with openFirewall = true.
}

The printer looks fine and works. but my scanner cannot be reached.

Troubleshooting Steps Taken:

  1. Initial Attempt with sane-airscan: airscan-discover found no devices.
  2. Switched to brscan4: Identified brscan4 as the correct driver for the scanner.
  3. NixOS Configuration Attempts:
    • Enabled hardware.sane.brscan4 module in nixos/modules/services/printing.nix.
    • Attempted to use hardware.sane.extraBackends = [ "brother4" ];.
    • Added brscan4 to environment.systemPackages.
  4. Network Configuration: Confirmed scanner is reachable on the network.
  5. SANE Debugging: Used SANE_DEBUG_DLL=255 SANE_DEBUG_BRSCAN4=255 scanimage -L to diagnose.
    • Critical Finding: Debug logs consistently show couldn't find backend 'brother4' errors. The scanimage wrapper provided by NixOS does not seem to include the necessary path for libsane-brother4.so.1 in its library search paths.
  6. Manual Path Forcing: Attempted to set SANE_PATH environment variable, but this was ignored by the wrapped scanimage command.
  7. Configuration Files:
    • etc/sane-config/dll.conf correctly lists brother4.
    • Removed a lingering airscan config from etc/sane-config/dll.d/.

Conclusion:

All attempts to configure the brscan4 driver via standard NixOS options and manual environment variable manipulation have failed. This strongly suggests a deeper, build-time issue within my specific NixOS flake configuration, where the sane-backends package is not being wrapped or built with the correct library search paths for the brscan4 backend.

Request for Assistance:

I am seeking assistance from the NixOS community to understand why the sane-backends package is failing to locate the brscan4 driver, despite being explicitly enabled and configured.

Please find the full SANE debug log attached/pasted below for detailed analysis.

Hi,

I have a Brother DCP-L3520CDWE

The following config works fine for both printing and scanning. I’ve nothing specific configured for brscan4.

    services.printing.enable = true;
    services.avahi = {
      enable = true;
      nssmdns4 = true;
      openFirewall = true;
    };
    services.printing.drivers = [ ];
    # Enable scanner support
    hardware.sane.enable = true;
2 Likes

The “simple” approach doesn’t work for me. I had to add

    sane = {
      enable = true;
      brscan4 = {
        enable = true;
        netDevices = {
          brother = {
            model = "MFC...";
            nodename = "BRWCxxxxx.local";
          };
        };
      };
    };

For the scanner to work properly I found that the nodename part of netDevices must include the .local part.

Node name can be found using avahi-browse for example:

avahi-browse -rd local _scanner._tcp

edit: removed irrelevant part of the post