1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 udev,
6 pkg-config,
7 glib,
8 xmlto,
9 wrapGAppsHook3,
10 docbook_xml_dtd_412,
11 docbook_xsl,
12 libxml2,
13 desktop-file-utils,
14 libusb1,
15 cups,
16 gdk-pixbuf,
17 pango,
18 atk,
19 libnotify,
20 gobject-introspection,
21 libsecret,
22 packagekit,
23 libcupsfilters,
24 gettext,
25 libtool,
26 autoconf-archive,
27 python3Packages,
28 autoreconfHook,
29 bash,
30 fetchpatch,
31}:
32
33stdenv.mkDerivation rec {
34 pname = "system-config-printer";
35 version = "1.5.18";
36
37 src = fetchFromGitHub {
38 owner = "openPrinting";
39 repo = pname;
40 rev = "v${version}";
41 sha256 = "sha256-l3HEnYycP56vZWREWkAyHmcFgtu09dy4Ds65u7eqNZk=";
42 };
43
44 prePatch = ''
45 # for automake
46 touch README ChangeLog
47 # for tests
48 substituteInPlace Makefile.am --replace /bin/bash ${bash}/bin/bash
49 '';
50
51 patches = [
52 ./detect_serverbindir.patch
53 # fix typeerror, remove on next release
54 (fetchpatch {
55 url = "https://github.com/OpenPrinting/system-config-printer/commit/399b3334d6519639cfe7f1c0457e2475b8ee5230.patch";
56 sha256 = "sha256-JCdGmZk2vRn3X1BDxOJaY3Aw8dr0ODVzi0oY20ZWfRs=";
57 excludes = [ "NEWS" ];
58 })
59
60 # switch to pep517 build tools
61 ./pep517.patch
62
63 # FIXME: remove when gettext is fixed
64 ./gettext-0.25.patch
65 ];
66
67 buildInputs = [
68 glib
69 udev
70 libusb1
71 cups
72 python3Packages.python
73 libnotify
74 gdk-pixbuf
75 pango
76 atk
77 packagekit
78 libsecret
79 ];
80
81 nativeBuildInputs = [
82 pkg-config
83 gettext
84 libtool
85 autoconf-archive
86 xmlto
87 libxml2
88 docbook_xml_dtd_412
89 docbook_xsl
90 desktop-file-utils
91 python3Packages.wrapPython
92 python3Packages.build
93 python3Packages.installer
94 python3Packages.setuptools
95 python3Packages.wheel
96 wrapGAppsHook3
97 autoreconfHook
98 gobject-introspection
99 ];
100
101 pythonPath =
102 with python3Packages;
103 requiredPythonModules [
104 pycups
105 pycurl
106 dbus-python
107 pygobject3
108 pycairo
109 pysmbc
110 ];
111
112 configureFlags = [
113 "--with-udev-rules"
114 "--with-udevdir=${placeholder "out"}/etc/udev"
115 "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
116 ];
117
118 stripDebugList = [
119 "bin"
120 "lib"
121 "etc/udev"
122 ];
123
124 doCheck = true;
125 doInstallCheck = true;
126
127 postInstall = ''
128 buildPythonPath "$out $pythonPath"
129 gappsWrapperArgs+=(
130 --prefix PATH : "$program_PATH"
131 --set CUPS_DATADIR "${libcupsfilters}/share/cups"
132 )
133
134 find $out/share/system-config-printer -name \*.py -type f -perm -0100 -print0 | while read -d "" f; do
135 patchPythonScript "$f"
136 done
137 patchPythonScript $out/etc/udev/udev-add-printer
138
139 substituteInPlace $out/etc/udev/rules.d/70-printers.rules \
140 --replace "udev-configure-printer" "$out/etc/udev/udev-configure-printer"
141 '';
142
143 meta = {
144 homepage = "https://github.com/openprinting/system-config-printer";
145 platforms = lib.platforms.linux;
146 license = lib.licenses.gpl2Plus;
147 };
148}