Scanners

From NixOS Wiki
Revision as of 12:16, 1 October 2017 by imported>Ciil

Scanners are handled by the SANE library:

#/etc/nixos/configuration.nix
{
  hardware.sane.enable = true;
}

Verification

To check quickly if your scanner is detected by SANE, you can use scanimage -L. If root only can detect the scanner, try adding your user in the scanner or lp group.

Extra backends

You can check on the official page of libsane if your scanner is supported. Some backends are proprietary and not installed by default (see below).

Note that the selection of the right set of backends by libsane depends on the LD_LIBRARY_PATH environment variable. nixos-rebuild switch is thus not enough to "install" a new backend, you need to logout/login again for changes to take effect.

HP

hardware.sane.extraBackends = [ pkgs.hplipWithPlugin ];

Epson

If your scanner is listed as supported by the epkowa backend :

hardware.sane.extraBackends = [ pkgs.epkowa ];

SnapScan firmware

Many scanners require firmware blobs which can be downloaded from the website of the scanner or extracted from the drivers they provide. Once you have the appropriate firmware you need to tell SANE where to find it in your configuration.nix:

{
  hardware.sane.enable = true;
  nixpkgs.config.sane.snapscanFirmware = pkgs.fetchurl {
    # https://wiki.ubuntuusers.de/Scanner/Epson_Perfection/#Unterstuetzte-Geraete
    url = "https://media-cdn.ubuntu-de.org/wiki/attachments/52/46/Esfw41.bin"; #Epson Perfection 2480
    sha256 = "00cv25v4xlrgp3di9bdfd07pffh9jq2j0hncmjv3c65m8bqhjglq";
  };
}

Brother

Brother currently provides four versions of scanner backends for various generations of its scanners. The newest (brscan4) is supported as a loadable submodule in NixOS. It can be activated by including the appropriate file in configuration.nix:

{
  imports = [ 
    <nixpkgs/nixos/modules/services/hardware/sane_extra_backends/brscan4.nix>
    ./hardware-configuration.nix
  ];  
}

Then just add a scanner in the sane module:

{
  hardware = {
    sane = {
      enable = true;
      brscan4 = {
        enable = true;
        netDevices = {
          home = { model = "MFC-L2700DN"; ip = "192.168.178.23"; };
        };
      };
    };
  };
}

It can take sane an actual reboot to pick up on the configuration changes.

Gimp plugin

To enable the Gimp plugin you need a special version of xsane :

{
  nixpkgs.config.packageOverrides = pkgs: {
    xsaneGimp = pkgs.xsane.override { gimpSupport = true; }; 
  };
}

and you also need to manually create a symlink:

ln -s /run/current-system/sw/bin/xsane ~/.gimp-2.8/plug-ins/xsane


Enable Network Scanning

As of right now ( 2017-08-16 ) the sane backend does not support overriding according to the  nixpkgs issue #17411. The workaround for this is to download the sane-extra-config.nix of michaelrus, put it into /etc/nixos/sane-extra-config.nix and use it in your configuration.nix via:

{ ... }:{
 imports = [
  ./sane-extra-config.nix
 ];
 ...
 hardware.sane.extraConfig."magicolor" = ''
   net 10.0.0.30 0x2098
 ''; # magicolor 1690mf
}

List of scanner firmware files