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