sane: Add support for the unfree Fujitsu ScanSnap drivers

This adds the scanner files already linked from the
`etc/sane.d/epjitsu.conf` file, which are extracted from the Windows
drivers and mirrored on GitHub.

Being a Japanese hardware vendor, Fujitsu’s software release &
licensing methods are horrifying, but their scanners are some of the
best, so we should definitly have discoverable support for them, which
this patch hopefully adds.

Inspiration was taken from the following sources:
https://www.josharcher.uk/code/install-scansnap-s1300-drivers-linux/
https://ubuntuforums.org/archive/index.php/t-1461915.html
https://github.com/stevleibelt/scansnap-firmware

+53 -2
+26 -1
nixos/modules/services/hardware/sane.nix
··· 4 4 5 5 let 6 6 7 - pkg = pkgs.sane-backends; 7 + pkg = pkgs.sane-backends.override { 8 + scanSnapDriversUnfree = config.hardware.sane.drivers.scanSnap.enable; 9 + scanSnapDriversPackage = config.hardware.sane.drivers.scanSnap.package; 10 + }; 8 11 9 12 sanedConf = pkgs.writeTextFile { 10 13 name = "saned.conf"; ··· 95 98 example = "192.168.0.16"; 96 99 description = '' 97 100 Network hosts that should be probed for remote scanners. 101 + ''; 102 + }; 103 + 104 + hardware.sane.drivers.scanSnap.enable = mkOption { 105 + type = types.bool; 106 + default = false; 107 + example = true; 108 + description = '' 109 + Whether to enable drivers for the Fujitsu ScanSnap scanners. 110 + 111 + The driver files are unfree and extracted from the Windows driver image. 112 + ''; 113 + }; 114 + 115 + hardware.sane.drivers.scanSnap.package = mkOption { 116 + type = types.package; 117 + default = pkgs.sane-drivers.epjitsu; 118 + description = '' 119 + Epjitsu driver package to use. Useful if you want to extract the driver files yourself. 120 + 121 + The process is described in the <literal>/etc/sane.d/epjitsu.conf</literal> file in 122 + the <literal>sane-backends</literal> package. 98 123 ''; 99 124 }; 100 125
+12 -1
pkgs/applications/graphics/sane/backends/default.nix
··· 2 2 , gettext, pkg-config, python3 3 3 , avahi, libgphoto2, libieee1284, libjpeg, libpng, libtiff, libusb1, libv4l, net-snmp 4 4 , curl, systemd, libxml2, poppler 5 + , sane-drivers 5 6 6 7 # List of { src name backend } attibute sets - see installFirmware below: 7 8 , extraFirmware ? [] 8 9 9 10 # For backwards compatibility with older setups; use extraFirmware instead: 10 11 , gt68xxFirmware ? null, snapscanFirmware ? null 12 + 13 + # Not included by default, scan snap drivers require fetching of unfree binaries. 14 + , scanSnapDriversUnfree ? false, scanSnapDriversPackage ? sane-drivers.epjitsu 11 15 }: 12 16 13 17 stdenv.mkDerivation { ··· 88 92 89 93 # net.conf conflicts with the file generated by the nixos module 90 94 rm $out/etc/sane.d/net.conf 91 - '' + lib.concatStrings (builtins.map installFirmware compatFirmware); 95 + 96 + '' 97 + + lib.optionalString scanSnapDriversUnfree '' 98 + # the ScanSnap drivers live under the epjitsu subdirectory, which was already created by the build but is empty. 99 + rmdir $out/share/sane/epjitsu 100 + ln -svT ${scanSnapDriversPackage} $out/share/sane/epjitsu 101 + '' 102 + + lib.concatStrings (builtins.map installFirmware compatFirmware); 92 103 93 104 meta = with lib; { 94 105 description = "SANE (Scanner Access Now Easy) backends";
+13
pkgs/applications/graphics/sane/drivers.nix
··· 1 + { lib, fetchFromGitHub }: 2 + 3 + { 4 + # Fujitsu ScanSnap 5 + epjitsu = fetchFromGitHub { 6 + name = "scansnap-firmware"; 7 + owner = "stevleibelt"; 8 + repo = "scansnap-firmware"; 9 + rev = "96c3a8b2a4e4f1ccc4e5827c5eb5598084fd17c8"; 10 + sha256 = "1inchnvaqyw9d0skpg8hp5rpn27c09q58lsr42by4bahpbx5qday"; 11 + meta.license = lib.licenses.unfree; 12 + }; 13 + }
+2
pkgs/top-level/all-packages.nix
··· 31830 31830 31831 31831 sane-backends = callPackage ../applications/graphics/sane/backends (config.sane or {}); 31832 31832 31833 + sane-drivers = callPackage ../applications/graphics/sane/drivers.nix {}; 31834 + 31833 31835 senv = callPackage ../applications/misc/senv { }; 31834 31836 31835 31837 brlaser = callPackage ../misc/cups/drivers/brlaser { };