|
| 1 | +{ |
| 2 | + autoreconfHook, |
| 3 | + cups, |
| 4 | + libjpeg, |
| 5 | + rpmextract, |
| 6 | + fetchurl, |
| 7 | + lib, |
| 8 | + stdenv, |
| 9 | +}: |
| 10 | + |
| 11 | +let |
| 12 | + srcdirs = { |
| 13 | + filter = "epson-inkjet-printer-filter-1.0.0"; |
| 14 | + driver = "epson-inkjet-printer-workforce-840-series-1.0.0"; |
| 15 | + }; |
| 16 | +in |
| 17 | +stdenv.mkDerivation (finalAttrs: { |
| 18 | + pname = "epson-inkjet-printer-workforce-840-series"; |
| 19 | + version = "1.0.0"; |
| 20 | + |
| 21 | + # The Epson may be unreliable, and it has been since sometime in |
| 22 | + # 2024. Non-browser requests using commands like fetchurl receive a |
| 23 | + # 403 error, an access denied response -- last checked on |
| 24 | + # 2025-08-21. |
| 25 | + # |
| 26 | + # Therefore, an archive.org link has been added as a fallback |
| 27 | + # option just in case. |
| 28 | + src = fetchurl { |
| 29 | + # NOTE: Don't forget to update the webarchive link too! |
| 30 | + urls = [ |
| 31 | + "https://download.ebz.epson.net/dsc/op/stable/SRPMS/epson-inkjet-printer-workforce-840-series-${finalAttrs.version}-1lsb3.2.src.rpm" |
| 32 | + "https://web.archive.org/web/https://download.ebz.epson.net/dsc/op/stable/SRPMS/epson-inkjet-printer-workforce-840-series-${finalAttrs.version}-1lsb3.2.src.rpm" |
| 33 | + ]; |
| 34 | + hash = "sha256-rTYnEmgzqR/wOZYYIe2rO9x2cX8s2qDyTuRaTjzJjbg="; |
| 35 | + }; |
| 36 | + sourceRoot = srcdirs.filter; |
| 37 | + |
| 38 | + nativeBuildInputs = [ |
| 39 | + autoreconfHook |
| 40 | + rpmextract |
| 41 | + ]; |
| 42 | + buildInputs = [ |
| 43 | + cups |
| 44 | + libjpeg |
| 45 | + ]; |
| 46 | + |
| 47 | + unpackPhase = '' |
| 48 | + runHook preUnpack |
| 49 | +
|
| 50 | + rpmextract "$src" |
| 51 | + for i in ${lib.concatStringsSep " " (builtins.attrValues srcdirs)}; do |
| 52 | + tar xvf "$i".tar.gz |
| 53 | + done |
| 54 | +
|
| 55 | + runHook postUnpack |
| 56 | + ''; |
| 57 | + |
| 58 | + # Both patches fix errors that occur when building with GCC 14. |
| 59 | + # |
| 60 | + # eps_raster_print-cast.patch fixes 'error: passing argument 5 of |
| 61 | + # ‘eps_raster_print’ from incompatible pointer type' in file |
| 62 | + # raster_to_epson.c |
| 63 | + # |
| 64 | + # include-raster-helper.patch fixes 'error: implicit declaration of |
| 65 | + # function' in files pagemanager.c and raster_to_epson.c |
| 66 | + patches = [ |
| 67 | + ./eps_raster_print-cast.patch |
| 68 | + ./include-raster-helper.patch |
| 69 | + ]; |
| 70 | + |
| 71 | + installPhase = |
| 72 | + let |
| 73 | + filterdir = "$out/lib/cups/filter"; |
| 74 | + docdir = "$out/share/doc/epson-inkjet-printer-workforce-840-series"; |
| 75 | + ppddir = "$out/share/cups/model/epson-inkjet-printer-workforce-840-series"; |
| 76 | + libdir = |
| 77 | + if stdenv.hostPlatform.isx86_64 then |
| 78 | + "lib64" |
| 79 | + else |
| 80 | + throw "Platforms other than x86_64-linux are not (yet) supported."; |
| 81 | + in |
| 82 | + '' |
| 83 | + runHook preInstall |
| 84 | +
|
| 85 | + mkdir -p "$out" "${docdir}" "${filterdir}" "${ppddir}" |
| 86 | + cp src/epson_inkjet_printer_filter "${filterdir}" |
| 87 | +
|
| 88 | + cp AUTHORS COPYING COPYING.EPSON COPYING.LIB "${docdir}" |
| 89 | +
|
| 90 | + cd ../${srcdirs.driver} |
| 91 | + cp Manual.txt README "${docdir}" |
| 92 | + for ppd in ppds/*; do |
| 93 | + substituteInPlace "$ppd" --replace-fail '/opt/epson-inkjet-printer-workforce-840-series/cups/lib' "$out/lib/cups" |
| 94 | + gzip -c "$ppd" > "${ppddir}/''${ppd#*/}" |
| 95 | + done |
| 96 | + cp -r resource watermark ${libdir} "$out" |
| 97 | +
|
| 98 | + runHook postInstall |
| 99 | + ''; |
| 100 | + |
| 101 | + meta = { |
| 102 | + description = "Proprietary CUPS drivers for Epson inkjet printers"; |
| 103 | + longDescription = '' |
| 104 | + This software is a filter program used with the Common UNIX Printing |
| 105 | + System (CUPS) under Linux. It supplies high quality printing with |
| 106 | + Seiko Epson Color Ink Jet Printers. |
| 107 | +
|
| 108 | + This printer driver is supporting the following printers. |
| 109 | +
|
| 110 | + Epson Stylus Office BX925 |
| 111 | + Epson WorkForce 840 |
| 112 | +
|
| 113 | + To use the driver adjust your configuration.nix file: |
| 114 | + ```nix |
| 115 | + { |
| 116 | + services.printing = { |
| 117 | + enable = true; |
| 118 | + drivers = [ pkgs.epson-inkjet-printer-workforce-840-series ]; |
| 119 | + }; |
| 120 | + } |
| 121 | + ``` |
| 122 | + ''; |
| 123 | + downloadPage = "http://download.ebz.epson.net/dsc/du/02/DriverDownloadInfo.do?LG2=EN&CN2=&DSCMI=16839&DSCCHK=3d7bc6bdfca08006abfb859fb1967183156a7252"; |
| 124 | + license = with lib.licenses; [ |
| 125 | + lgpl21 |
| 126 | + epson |
| 127 | + ]; |
| 128 | + maintainers = with lib.maintainers; [ heichro ]; |
| 129 | + platforms = [ "x86_64-linux" ]; |
| 130 | + }; |
| 131 | +}) |
0 commit comments