21 , withNonFreePlugins ? false
26 description = "Epson Scan 2 scanner driver for many modern Epson scanners and multifunction printers";
29 system = stdenv.hostPlatform.system;
32 url = "https://download3.ebz.epson.net/dsc/f/03/00/15/17/69/0ef02802c476a6564f13cac929859c394f40326a/epsonscan2-6.7.63.0-1.src.tar.gz";
33 hash = "sha256-ZLnbIk0I7g6ext5anPD+/lD4qNlk6f2fL0xdIWLcfbY=";
36 "i686-linux" = fetchzip {
37 name = "${pname}-bundle";
38 url = "https://download3.ebz.epson.net/dsc/f/03/00/15/17/67/ceae6a02aaa81cb61012899987fbb5ab891b6ab2/epsonscan2-bundle-6.7.63.0.i686.deb.tar.gz";
39 hash = "sha256-h9beAzNdjOhTlZqW0rJbSQXGOpvFRGvTcWw0ZtOqiYY=";
42 "x86_64-linux" = fetchzip {
43 name = "${pname}-bundle";
44 url = "https://download3.ebz.epson.net/dsc/f/03/00/15/17/68/050e5a55ed90f4efb4ca3bdd34e5797b149443ca/epsonscan2-bundle-6.7.63.0.x86_64.deb.tar.gz";
45 hash = "sha256-+S17FfS2h4zZCvE6W+yZvdJb6+OWYTt0ZWCA+pe1NZc=";
47 }."${system}" or (throw "Unsupported system: ${system}");
51 inherit pname src version;
56 url = "https://github.com/flathub/net.epson.epsonscan2/raw/master/patches/epsonscan2-crash.patch";
57 hash = "sha256-srMxlFfnZuJ3ed5veFcJIiZuW27F/3xOS0yr4ywn4FI=";
60 url = "https://raw.githubusercontent.com/flathub/net.epson.epsonscan2/master/patches/epsonscan2-oob-container.patch";
61 hash = "sha256-FhXZT0bIBYwdFow2USRJl8Q7j2eqpq98Hh0lHFQlUQY=";
64 url = "https://raw.githubusercontent.com/flathub/net.epson.epsonscan2/master/patches/epsonscan2-xdg-open.patch";
65 hash = "sha256-4ih3vZjPwWiiAxKfpLIwbbsk1K2oXSuxGbT5PVwfUsc=";
70 substituteInPlace src/Controller/Src/Scanner/Engine.cpp \
71 --replace '@KILLALL@' ${killall}/bin/killall
73 substituteInPlace src/Controller/Src/Filter/GetOrientation.cpp \
74 --replace '@OCR_ENGINE_GETROTATE@' $out/libexec/epsonscan2-ocr/ocr-engine-getrotate
79 ] ++ lib.optionals withGui [
80 imagemagick # to make icons
82 ] ++ lib.optionals withNonFreePlugins [
92 ] ++ lib.optionals withGui [
95 ] ++ lib.optionals withNonFreePlugins [
100 # The non-free (Debian) packages uses this directory structure so do the same when compiling
101 # from source so we can easily merge them.
102 "-DCMAKE_INSTALL_LIBDIR=lib/${system}-gnu"
103 ] ++ lib.optionals (!withGui) [
108 # But when we put all the libraries in lib/${system}-gnu, then SANE can't find the
109 # required libraries so create a symlink to where it expects them to be.
110 mkdir -p $out/lib/sane
111 for file in $out/lib/${system}-gnu/sane/*.so.*; do
112 ln -s $file $out/lib/sane/
114 '' + lib.optionalString withGui ''
115 # The icon file extension is .ico but it's actually a png!
116 mkdir -p $out/share/icons/hicolor/{48x48,128x128}/apps
117 convert $src/Resources/Icons/escan2_app.ico -resize 48x48 $out/share/icons/hicolor/48x48/apps/epsonscan2.png
118 convert $src/Resources/Icons/escan2_app.ico -resize 128x128 $out/share/icons/hicolor/128x128/apps/epsonscan2.png
119 '' + lib.optionalString withNonFreePlugins ''
120 ar xf ${bundle}/plugins/epsonscan2-non-free-plugin_*.deb
125 desktopItems = lib.optionals withGui [
130 desktopName = "Epson Scan 2";
131 genericName = "Epson Scan 2";
132 comment = description;
133 categories = [ "Graphics" "Scanning" ];
139 mainProgram = "epsonscan2";
141 Epson Scan 2 scanner driver including optional non-free plugins such as OCR and network
144 To use the SANE backend:
146 hardware.sane.extraBackends = [ pkgs.epsonscan2 ];
149 Overrides can be used to customise this package. For example, to enable non-free plugins and
150 disable the Epson GUI:
152 pkgs.epsonscan2.override { withNonFreePlugins = true; withGui = false; }
155 homepage = "https://support.epson.net/linux/en/epsonscan2.php";
156 platforms = [ "i686-linux" "x86_64-linux" ];
157 sourceProvenance = with lib.sourceTypes; [ fromSource ] ++ lib.optionals withNonFreePlugins [ binaryNativeCode ];
158 license = with lib.licenses; if withNonFreePlugins then unfree else lgpl21Plus;
159 maintainers = with lib.maintainers; [ james-atkins ];