1{
2 lib,
3 stdenv,
4 fetchurl,
5 foomatic-filters,
6 bc,
7 ghostscript,
8 systemd,
9 udevCheckHook,
10 vim,
11 time,
12}:
13
14stdenv.mkDerivation rec {
15 pname = "foo2zjs";
16 version = "20210116";
17
18 src = fetchurl {
19 url = "http://www.loegria.net/mirrors/foo2zjs/foo2zjs-${version}.tar.gz";
20 sha256 = "14x3wizvncdy0xgvmcx541qanwb7bg76abygqy17bxycn1zh5r1x";
21 };
22
23 nativeBuildInputs = [
24 bc
25 foomatic-filters
26 ghostscript
27 vim
28 udevCheckHook
29 ];
30
31 buildInputs = [
32 systemd
33 ];
34
35 patches = [
36 ./no-hardcode-fw.diff
37 # Support HBPL1 printers. Updated patch based on
38 # https://www.dechifro.org/hbpl/
39 ./hbpl1.patch
40 # Fix "Unimplemented paper code" error for hbpl1 printers
41 # https://github.com/mikerr/foo2zjs/pull/2
42 ./papercode-format-fix.patch
43 # Fix AirPrint color printing for Dell 1250c
44 # See https://github.com/OpenPrinting/cups/issues/272
45 ./dell1250c-color-fix.patch
46 ];
47
48 makeFlags = [
49 "PREFIX=$(out)"
50 "APPL=$(out)/share/applications"
51 "PIXMAPS=$(out)/share/pixmaps"
52 "UDEVBIN=$(out)/bin"
53 "UDEVDIR=$(out)/etc/udev/rules.d"
54 "UDEVD=${systemd}/sbin/udevd"
55 "LIBUDEVDIR=$(out)/lib/udev/rules.d"
56 "USBDIR=$(out)/etc/hotplug/usb"
57 "FOODB=$(out)/share/foomatic/db/source"
58 "MODEL=$(out)/share/cups/model"
59 ];
60
61 installFlags = [ "install-hotplug" ];
62
63 postPatch = ''
64 touch all-test
65 sed -e "/BASENAME=/iPATH=$out/bin:$PATH" -i *-wrapper *-wrapper.in
66 sed -e "s@PREFIX=/usr@PREFIX=$out@" -i *-wrapper{,.in}
67 sed -e "s@/usr/share@$out/share@" -i hplj10xx_gui.tcl
68 sed -e "s@\[.*-x.*/usr/bin/logger.*\]@type logger >/dev/null 2>\&1@" -i *wrapper{,.in}
69 sed -e '/install-usermap/d' -i Makefile
70 sed -e "s@/etc/hotplug/usb@$out&@" -i *rules*
71 sed -e "s@/usr@$out@g" -i hplj1020.desktop
72 sed -e "/PRINTERID=/s@=.*@=$out/bin/usb_printerid@" -i hplj1000
73 '';
74
75 nativeCheckInputs = [ time ];
76 doCheck = false; # fails to find its own binary. Also says "Tests will pass only if you are using ghostscript-8.71-16.fc14".
77 doInstallCheck = true;
78
79 preInstall = ''
80 mkdir -pv $out/{etc/udev/rules.d,lib/udev/rules.d,etc/hotplug/usb}
81 mkdir -pv $out/share/foomatic/db/source/{opt,printer,driver}
82 mkdir -pv $out/share/cups/model
83 mkdir -pv $out/share/{applications,pixmaps}
84
85 mkdir -pv "$out/bin"
86 cp -v getweb arm2hpdl "$out/bin"
87 '';
88
89 meta = with lib; {
90 description = "ZjStream printer drivers";
91 maintainers = with maintainers; [
92 raskin
93 ];
94 platforms = platforms.linux;
95 license = licenses.gpl2Plus;
96 };
97}