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