Scanners: Difference between revisions

From NixOS Wiki
imported>Ciil
No edit summary
imported>HLandau
No edit summary
Line 1: Line 1:
Scanners are handled by the SANE library:
==Installing scanner support==
Scanner support is provided by the SANE library. To enable scanner support, amend <tt>/etc/nixos/configuration.nix</tt>:


<syntaxhighlight lang="nix">#/etc/nixos/configuration.nix
<syntaxhighlight lang="nix">
{
{
  ...
   hardware.sane.enable = true;
   hardware.sane.enable = true;
}</syntaxhighlight>
  ...
}
</syntaxhighlight>
 
{{evaluate}}


== Verification ==
==Testing scanner support==


To check quickly if your scanner is detected by SANE, you can use <code>scanimage -L</code>. If root only can detect the scanner, try adding your user in the <code>scanner</code> or <code>lp</code> group.
To determine if your scanner is supported by SANE:
<syntaxhighlight lang="console">
$ scanimage -L
</syntaxhighlight>


== Extra backends ==
If you can only see scanners when running as root, try adding the user to the <tt>scanner</tt> or <tt>lp</tt> groups:
<syntaxhighlight lang="console">
$ sudo usermod -a -G scanner,lp username
</syntaxhighlight>


You can check on the [http://www.sane-project.org/sane-supported-devices.html official page of libsane] if your scanner is supported. Some backends are proprietary and not installed by default (see below).
==Supported backends==
See the [http://www.sane-project.org/sane-supported-devices.html Supported Devices] page to see if your scanner is supported. Some backends are proprietary and are not installed by default; see below.


Note that the selection of the right set of backends by libsane depends on the <code>LD_LIBRARY_PATH</code> environment variable. <code>nixos-rebuild switch</code> is thus not enough to "install" a new backend, you need to logout/login again for changes to take effect.
Note: The detection of installed backends by SANE depends on the <tt>LD_LIBRARY_PATH</tt> environment variable, which is set at login. You will need to logout and back in again for backend changes to take effect after <tt>nixos-rebuild switch</tt>.


=== HP ===
===HP===


<syntaxhighlight lang="nix">hardware.sane.extraBackends = [ pkgs.hplipWithPlugin ];</syntaxhighlight>
<syntaxhighlight lang="nix">hardware.sane.extraBackends = [ pkgs.hplipWithPlugin ];</syntaxhighlight>


=== Epson ===
===Epson===
 
If your scanner is listed as supported by the <tt>epkowa</tt> backend:
If your scanner is listed as supported by the epkowa backend :


<syntaxhighlight lang="nix">hardware.sane.extraBackends = [ pkgs.epkowa ];</syntaxhighlight>
<syntaxhighlight lang="nix">hardware.sane.extraBackends = [ pkgs.epkowa ];</syntaxhighlight>


=== SnapScan firmware ===
===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:
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:
Line 39: Line 51:
}</syntaxhighlight>
}</syntaxhighlight>


=== Brother ===
===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:
Brother currently provides four different scanner backends for various generations of its scanners. The newest (brscan4) is supported as a loadable submodule in NixOS. It can be activated by importing the appropriate file into <tt>/etc/nixos/configuration.nix</tt>:


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


Line 52: Line 66:


<syntaxhighlight lang="nix">{
<syntaxhighlight lang="nix">{
  ...
   hardware = {
   hardware = {
     sane = {
     sane = {
Line 63: Line 78:
     };
     };
   };
   };
  ...
}</syntaxhighlight>
}</syntaxhighlight>


It ''can'' take sane an actual reboot to pick up on the configuration changes.
In some cases, configuration changes may not take effect until after a reboot.
 
==GIMP support==
To enable support for scanning in GIMP:


== Gimp plugin ==
<ol>
To enable the Gimp plugin you need a special version of xsane :
<li>You need to install a special version of xsane, which you can enable by amending <tt>/etc/nixos/configuration.nix</tt> as follows:


<syntaxhighlight lang="nix">{
<syntaxhighlight lang="nix">{
  ...
   nixpkgs.config.packageOverrides = pkgs: {
   nixpkgs.config.packageOverrides = pkgs: {
     xsaneGimp = pkgs.xsane.override { gimpSupport = true; };  
     xsaneGimp = pkgs.xsane.override { gimpSupport = true; };  
   };
   };
}</syntaxhighlight>
  ...
}</syntaxhighlight></li>
<li>Rebuild: <syntaxhighlight lang="console">$ sudo nixos-rebuild switch</syntaxhighlight></li>
<li>Finally, you will need to manually create a symlink:
<syntaxhighlight lang="console">$ ln -s /run/current-system/sw/bin/xsane ~/.gimp-2.8/plug-ins/xsane</syntaxhighlight>
</li></ol>


and you also need to manually create a symlink:
==Network scanning==


<syntaxhighlight lang="bash">ln -s /run/current-system/sw/bin/xsane ~/.gimp-2.8/plug-ins/xsane</syntaxhighlight>
Currently (2017-08-16) the SANE backend does not support overriding according to {{issue|17411|nixpkgs issue #17411}}. The workaround for this is to download [https://raw.githubusercontent.com/michalrus/dotfiles/d943be3089aa436e07cea5f22d829402936a9229/.nixos-config.symlink/modules/sane-extra-config.nix michaelrus's sane-extra-config.nix], copy it to <code>/etc/nixos/sane-extra-config.nix</code> and import it in <code>/etc/nixos/configuration.nix</code> as follows:


 
<syntaxhighlight lang="nix">{
== Enable Network Scanning ==
  ...
 
  imports = [
As of right now ( 2017-08-16 ) the sane backend does not support overriding according to the {{issue|17411|nixpkgs issue #17411}}. The workaround for this is to download the [https://raw.githubusercontent.com/michalrus/dotfiles/d943be3089aa436e07cea5f22d829402936a9229/.nixos-config.symlink/modules/sane-extra-config.nix sane-extra-config.nix of michaelrus], put it into <code>/etc/nixos/sane-extra-config.nix</code> and use it in your <code>configuration.nix</code> via:
    ...
 
    ./sane-extra-config.nix
<syntaxhighlight lang="nix">{ ... }:{
    ...
imports = [
  ];
  ./sane-extra-config.nix
];
  ...
  ...
  hardware.sane.extraConfig."magicolor" = ''
  hardware.sane.extraConfig."magicolor" = ''
   net 10.0.0.30 0x2098
   net 10.0.0.30 0x2098
  ''; # magicolor 1690mf
  ''; # Magicolor 1690mf
...
}</syntaxhighlight>
}</syntaxhighlight>


== List of scanner firmware files ==
==See also==
 
===Scanner firmware files===
* [https://sites.google.com/site/rameyarnaud/media/books/agfa-scanners-with-linux Agfa Snapscan e40]
* [https://sites.google.com/site/rameyarnaud/media/books/agfa-scanners-with-linux Agfa Snapscan e40]
* [https://download.tuxfamily.org/xcfaudio/ Misc Agfa Snapscan] | [https://ipfs.io/ipfs/QmZJ2SfpfYUAS23TujhcdLpTox1SW3Dw3MoCej9GAfs4ya IPFS mirror]
* [https://download.tuxfamily.org/xcfaudio/ Misc Agfa Snapscan] | [https://ipfs.io/ipfs/QmZJ2SfpfYUAS23TujhcdLpTox1SW3Dw3MoCej9GAfs4ya IPFS mirror]
[[Category:Configuration]][[Category:Hardware]]

Revision as of 18:48, 24 October 2017

Installing scanner support

Scanner support is provided by the SANE library. To enable scanner support, amend /etc/nixos/configuration.nix:

{
  ...
  hardware.sane.enable = true;
  ...
}

Testing scanner support

To determine if your scanner is supported by SANE:

$ scanimage -L

If you can only see scanners when running as root, try adding the user to the scanner or lp groups:

$ sudo usermod -a -G scanner,lp username

Supported backends

See the Supported Devices page to see if your scanner is supported. Some backends are proprietary and are not installed by default; see below.

Note: The detection of installed backends by SANE depends on the LD_LIBRARY_PATH environment variable, which is set at login. You will need to logout and back in again for backend changes to take effect after nixos-rebuild switch.

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 different scanner backends for various generations of its scanners. The newest (brscan4) is supported as a loadable submodule in NixOS. It can be activated by importing the appropriate file into /etc/nixos/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"; };
        };
      };
    };
  };
  ...
}

In some cases, configuration changes may not take effect until after a reboot.

GIMP support

To enable support for scanning in GIMP:

  1. You need to install a special version of xsane, which you can enable by amending /etc/nixos/configuration.nix as follows:
    {
      ...
      nixpkgs.config.packageOverrides = pkgs: {
        xsaneGimp = pkgs.xsane.override { gimpSupport = true; }; 
      };
      ...
    }
    
  2. Rebuild:
    $ sudo nixos-rebuild switch
    
  3. Finally, you will need to manually create a symlink:
    $ ln -s /run/current-system/sw/bin/xsane ~/.gimp-2.8/plug-ins/xsane
    

Network scanning

Currently (2017-08-16) the SANE backend does not support overriding according to nixpkgs issue #17411. The workaround for this is to download michaelrus's sane-extra-config.nix, copy it to /etc/nixos/sane-extra-config.nix and import it in /etc/nixos/configuration.nix as follows:

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

See also

Scanner firmware files