NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.07k stars 14.08k forks source link

sane doesn't see sane-airscan #96635

Closed tex closed 4 years ago

tex commented 4 years ago

/etc/nixos/configuration.nix:

    hardware.sane =
      { enable = true;
      extraBackends = [ pkgs.sane-airscan ];
    };

After switching to this config, it is interesting that there is no /etc/sane folder in resulting system...

[root@nixos ~milan]# airscan-discover
[devices]
  Xerox WorkCentre 3025 (XRX9C934E3E92AF) = http://192.168.1.171:8018/wsd/scan, WSD

But scanimage doesn't see the scanner, because it doesn't see sane-airscan:

[root@nixos ~milan]# SANE_DEBUG_DLL=3 scanimage -L
[21:45:05.641986] [sanei_debug] Setting debug level of dll to 3.
[21:45:05.642118] [dll] sane_init: SANE dll backend version 1.0.13 from sane-backends 1.0.30
[21:45:05.642164] [dll] sane_init/read_dlld: using config directory `/nix/store/3ka3l1pvh8rhcl3niksqbadpsblwisyd-sane-backends-1.0.30/etc/sane.d/dll.d'
[21:45:05.642226] [dll] add_backend: adding backend `net'
[21:45:05.642245] [dll] add_backend: adding backend `abaton'
[21:45:05.642261] [dll] add_backend: adding backend `agfafocus'
[21:45:05.642287] [dll] add_backend: adding backend `apple'
[21:45:05.642311] [dll] add_backend: adding backend `artec'
[21:45:05.642324] [dll] add_backend: adding backend `artec_eplus48u'
[21:45:05.642339] [dll] add_backend: adding backend `as6e'
[21:45:05.642352] [dll] add_backend: adding backend `avision'
[21:45:05.642365] [dll] add_backend: adding backend `bh'
[21:45:05.642378] [dll] add_backend: adding backend `canon'
[21:45:05.642391] [dll] add_backend: adding backend `canon630u'
[21:45:05.642404] [dll] add_backend: adding backend `canon_dr'
[21:45:05.642418] [dll] add_backend: adding backend `cardscan'
[21:45:05.642431] [dll] add_backend: adding backend `coolscan'
[21:45:05.642444] [dll] add_backend: adding backend `coolscan3'
[21:45:05.642459] [dll] add_backend: adding backend `dell1600n_net'
[21:45:05.642472] [dll] add_backend: adding backend `dmc'
[21:45:05.642485] [dll] add_backend: adding backend `epjitsu'
[21:45:05.642498] [dll] add_backend: adding backend `epson2'
[21:45:05.642511] [dll] add_backend: adding backend `epsonds'
[21:45:05.642524] [dll] add_backend: adding backend `escl'
[21:45:05.642538] [dll] add_backend: adding backend `fujitsu'
[21:45:05.642551] [dll] add_backend: adding backend `genesys'
[21:45:05.642564] [dll] add_backend: adding backend `gt68xx'
[21:45:05.642577] [dll] add_backend: adding backend `hp'
[21:45:05.642591] [dll] add_backend: adding backend `hp3500'
[21:45:05.642604] [dll] add_backend: adding backend `hp3900'
[21:45:05.642617] [dll] add_backend: adding backend `hp4200'
[21:45:05.642630] [dll] add_backend: adding backend `hp5400'
[21:45:05.642643] [dll] add_backend: adding backend `hp5590'
[21:45:05.642661] [dll] add_backend: adding backend `hpljm1005'
[21:45:05.642674] [dll] add_backend: adding backend `hpsj5s'
[21:45:05.642687] [dll] add_backend: adding backend `hs2p'
[21:45:05.642700] [dll] add_backend: adding backend `ibm'
[21:45:05.642713] [dll] add_backend: adding backend `kodak'
[21:45:05.642726] [dll] add_backend: adding backend `kodakaio'
[21:45:05.642739] [dll] add_backend: adding backend `kvs1025'
[21:45:05.642753] [dll] add_backend: adding backend `kvs20xx'
[21:45:05.642766] [dll] add_backend: adding backend `kvs40xx'
[21:45:05.642779] [dll] add_backend: adding backend `leo'
[21:45:05.642792] [dll] add_backend: adding backend `lexmark'
[21:45:05.642806] [dll] add_backend: adding backend `ma1509'
[21:45:05.642819] [dll] add_backend: adding backend `magicolor'
[21:45:05.642832] [dll] add_backend: adding backend `matsushita'
[21:45:05.642855] [dll] add_backend: adding backend `microtek'
[21:45:05.642873] [dll] add_backend: adding backend `microtek2'
[21:45:05.642887] [dll] add_backend: adding backend `mustek'
[21:45:05.642900] [dll] add_backend: adding backend `mustek_usb'
[21:45:05.642913] [dll] add_backend: adding backend `mustek_usb2'
[21:45:05.642927] [dll] add_backend: adding backend `nec'
[21:45:05.642940] [dll] add_backend: adding backend `niash'
[21:45:05.642954] [dll] add_backend: adding backend `pie'
[21:45:05.642967] [dll] add_backend: adding backend `pieusb'
[21:45:05.642983] [dll] add_backend: adding backend `pint'
[21:45:05.642997] [dll] add_backend: adding backend `pixma'
[21:45:05.643010] [dll] add_backend: adding backend `plustek'
[21:45:05.643023] [dll] add_backend: adding backend `qcam'
[21:45:05.643036] [dll] add_backend: adding backend `ricoh'
[21:45:05.643050] [dll] add_backend: adding backend `ricoh2'
[21:45:05.643063] [dll] add_backend: adding backend `rts8891'
[21:45:05.643077] [dll] add_backend: adding backend `s9036'
[21:45:05.643091] [dll] add_backend: adding backend `sceptre'
[21:45:05.643104] [dll] add_backend: adding backend `sharp'
[21:45:05.643118] [dll] add_backend: adding backend `sm3600'
[21:45:05.643132] [dll] add_backend: adding backend `sm3840'
[21:45:05.643145] [dll] add_backend: adding backend `snapscan'
[21:45:05.643158] [dll] add_backend: adding backend `sp15c'
[21:45:05.643172] [dll] add_backend: adding backend `tamarack'
[21:45:05.643185] [dll] add_backend: adding backend `teco1'
[21:45:05.643198] [dll] add_backend: adding backend `teco2'
[21:45:05.643211] [dll] add_backend: adding backend `teco3'
[21:45:05.643224] [dll] add_backend: adding backend `u12'
[21:45:05.643237] [dll] add_backend: adding backend `umax'
[21:45:05.643249] [dll] add_backend: adding backend `umax1220u'
[21:45:05.643262] [dll] add_backend: adding backend `v4l'
[21:45:05.643274] [dll] add_backend: adding backend `xerox_mfp'
[21:45:05.643306] [dll] sane_get_devices

@zaninime

tex commented 4 years ago

@doronbehar Thanks Doron, as you use airscan, do you see in this my config something wrong?

doronbehar commented 4 years ago

it is interesting that there is no /etc/sane

That's not ideal but it's the current way things are designed: When you build your system, it writes to /etc/set-environment or alike, a export SANE_CONFIG_DIR=/nix/store/... which should contain the files sane uses to find the configs.

Me and others have noticed this is bad design, see https://github.com/NixOS/nixpkgs/issues/90184 and https://github.com/NixOS/nixpkgs/issues/90201 . Perhaps we should write wrappers for simple-scan and similar packages that would contain the requested sane config via SANE_CONFIG_DIR in these packages' wrappers' environment.

Could you please try running this command, on the same shell you run scanimage -L:

grep airscan -R $SANE_CONFIG_DIR
zaninime commented 4 years ago

@tex, did you logout/login after switching the config? Sane relies on LD_LIBRARY_PATH, which will be updated next time you initialize your session (inaccurate explanation, but it's too keep it simple)

tex commented 4 years ago

Thanks all! It detects scanner after restart. Sorry I didn't try, I am long term user of Linux so I almost forget that restart may sometime help :) It is detected only when running as root, but I remember some tip in NixOS wiki about that.

But my scanner doesn't work out of the box even it is detected:

[root@nixos nixpkgs]# scanimage -L
device `airscan:w0:Xerox WorkCentre 3025 (XRX9C934E3E92AF)' is a WSD Xerox WorkCentre 3025 (XRX9C934E3E92AF) WSD network scanner

It connects, scanner is scanning, but xsane complains: Error during read: Error during device I/O.

tex commented 4 years ago

I am trying to provide debug info so author of sane-airscan can help me, it is neccessary to modify /etc/sane.d/airscan.conf file:

[debug]
trace = ~/airscan/trace
enable = true

Do you have idea how to do that in NixOS? Modify package of sane-airscan directly (I have local clone of nixpkgs)?

doronbehar commented 4 years ago

Do you have idea how to do that in NixOS? Modify package of sane-airscan directly (I have local clone of nixpkgs)?

That's not possible without some hacking. Try this ugly patch to Nixpkgs:

diff --git i/pkgs/applications/graphics/sane/config.nix w/pkgs/applications/graphics/sane/config.nix
index 2ef1e26f5ac..a7c8db8d39b 100644
--- i/pkgs/applications/graphics/sane/config.nix
+++ w/pkgs/applications/graphics/sane/config.nix
@@ -16,7 +16,14 @@ let installSanePath = path: ''
           if [ "$name" = "dll.conf" ] || [ "$name" = "saned.conf" ] || [ "$name" = "net.conf" ]; then
             cat "$conf" >> "$out/etc/sane.d/$name"
           else
-            symlink "$conf" "$out/etc/sane.d/$name"
+            if [ "$name" = airscan.conf ]; then
+              cat "$conf" > "$out/etc/sane.d/$name"
+              echo '[debug]' >> "$out/etc/sane.d/$name"
+              echo 'trace = ~/airscan/trace' >> "$out/etc/sane.d/$name"
+              echo 'enable = true' >> "$out/etc/sane.d/$name"
+            else
+              symlink "$conf" "$out/etc/sane.d/$name"
+            fi
           fi
         done
       fi
diff --git i/pkgs/top-level/all-packages.nix w/pkgs/top-level/all-packages.nix
index 04e10fd7c1b..4569d5fb399 100644
--- i/pkgs/top-level/all-packages.nix
+++ w/pkgs/top-level/all-packages.nix
@@ -27066,6 +27066,8 @@ in

   mkSaneConfig = callPackage ../applications/graphics/sane/config.nix { };

+  mySaneConf = mkSaneConfig { paths = [ sane-airscan ]; };
+
   sane-frontends = callPackage ../applications/graphics/sane/frontends.nix { };

   sanoid = callPackage ../tools/backup/sanoid { };

And then, run whatever command you need to run with:

env SANE_CONFIG_DIR=$(nix-build -A mySaneConf)/etc/sane.d