1{
2 lib,
3 stdenv,
4 fetchFromGitLab,
5 gitUpdater,
6 pkg-config,
7 meson,
8 ninja,
9 libevdev,
10 mtdev,
11 udev,
12 libwacom,
13 documentationSupport ? false,
14 doxygen,
15 graphviz,
16 runCommand,
17 eventGUISupport ? false,
18 cairo,
19 glib,
20 gtk3,
21 testsSupport ? false,
22 check,
23 valgrind,
24 python3,
25 nixosTests,
26 wayland-scanner,
27 udevCheckHook,
28}:
29
30let
31 mkFlag = optSet: flag: "-D${flag}=${lib.boolToString optSet}";
32
33 sphinx-build =
34 let
35 env = python3.withPackages (
36 pp: with pp; [
37 sphinx
38 recommonmark
39 sphinx-rtd-theme
40 ]
41 );
42 in
43 # Expose only the sphinx-build binary to avoid contaminating
44 # everything with Sphinx’s Python environment.
45 runCommand "sphinx-build" { } ''
46 mkdir -p "$out/bin"
47 ln -s "${env}/bin/sphinx-build" "$out/bin"
48 '';
49in
50
51stdenv.mkDerivation rec {
52 pname = "libinput";
53 version = "1.29.0";
54
55 outputs = [
56 "bin"
57 "out"
58 "dev"
59 ];
60
61 src = fetchFromGitLab {
62 domain = "gitlab.freedesktop.org";
63 owner = "libinput";
64 repo = "libinput";
65 rev = version;
66 hash = "sha256-wZRec6zIOALy1O6/NRRl0VxuS16SiL5SjXsley4K+c0=";
67 };
68
69 patches = [
70 ./udev-absolute-path.patch
71 ];
72
73 nativeBuildInputs = [
74 pkg-config
75 meson
76 ninja
77 udevCheckHook
78 ]
79 ++ lib.optionals documentationSupport [
80 doxygen
81 graphviz
82 sphinx-build
83 ];
84
85 buildInputs = [
86 libevdev
87 mtdev
88 libwacom
89 (python3.withPackages (
90 pp: with pp; [
91 pp.libevdev # already in scope
92 pyudev
93 pyyaml
94 setuptools
95 ]
96 ))
97 ]
98 ++ lib.optionals eventGUISupport [
99 # GUI event viewer
100 cairo
101 glib
102 gtk3
103 wayland-scanner
104 ];
105
106 propagatedBuildInputs = [
107 udev
108 ];
109
110 nativeCheckInputs = [
111 check
112 valgrind
113 ];
114
115 mesonFlags = [
116 (mkFlag documentationSupport "documentation")
117 (mkFlag eventGUISupport "debug-gui")
118 (mkFlag testsSupport "tests")
119 "--sysconfdir=/etc"
120 "--libexecdir=${placeholder "bin"}/libexec"
121 ];
122
123 doCheck = testsSupport && stdenv.hostPlatform == stdenv.buildPlatform;
124
125 doInstallCheck = true;
126
127 postPatch = ''
128 patchShebangs \
129 test/symbols-leak-test \
130 test/check-leftover-udev-rules.sh \
131 test/helper-copy-and-exec-from-tmp.sh
132
133 # Don't create an empty directory under /etc.
134 sed -i "/install_emptydir(dir_etc \/ 'libinput')/d" meson.build
135 '';
136
137 passthru = {
138 tests = {
139 libinput-module = nixosTests.libinput;
140 };
141 updateScript = gitUpdater {
142 patchlevel-unstable = true;
143 };
144 };
145
146 meta = with lib; {
147 description = "Handles input devices in Wayland compositors and provides a generic X.Org input driver";
148 mainProgram = "libinput";
149 homepage = "https://www.freedesktop.org/wiki/Software/libinput/";
150 license = licenses.mit;
151 platforms = platforms.linux;
152 maintainers = with maintainers; [ codyopel ];
153 teams = [ teams.freedesktop ];
154 changelog = "https://gitlab.freedesktop.org/libinput/libinput/-/releases/${version}";
155 badPlatforms = [
156 # Mandatory shared library.
157 lib.systems.inspect.platformPatterns.isStatic
158 ];
159 };
160}