1{ lib
2, stdenv
3, fetchurl
4, meson
5, ninja
6, pkg-config
7, bison
8, doxygen
9, xkeyboard_config
10, libxcb
11, libxml2
12, python3
13, libX11
14 # To enable the "interactive-wayland" subcommand of xkbcli. This is the
15 # wayland equivalent of `xev` on X11.
16, xorg
17, withWaylandTools ? stdenv.isLinux
18, wayland
19, wayland-protocols
20, wayland-scanner
21, testers
22}:
23
24stdenv.mkDerivation (finalAttrs: {
25 pname = "libxkbcommon";
26 version = "1.7.0";
27
28 src = fetchurl {
29 url = with finalAttrs; "https://xkbcommon.org/download/${pname}-${version}.tar.xz";
30 hash = "sha256-ZXgvChCktFWvnGuqtwQOL1N1IMqi7CCSgFzf02hjskc=";
31 };
32
33 patches = [
34 # Disable one Xvfb test as it fails for permission checks.
35 ./disable-x11com.patch
36 ];
37
38 outputs = [ "out" "dev" "doc" ];
39
40 depsBuildBuild = [ pkg-config ];
41 nativeBuildInputs = [ meson ninja pkg-config bison doxygen xorg.xvfb ]
42 ++ lib.optional withWaylandTools wayland-scanner;
43 buildInputs = [ xkeyboard_config libxcb libxml2 ]
44 ++ lib.optionals withWaylandTools [ wayland wayland-protocols ];
45 nativeCheckInputs = [ python3 ];
46
47 mesonFlags = [
48 "-Dxkb-config-root=${xkeyboard_config}/etc/X11/xkb"
49 "-Dxkb-config-extra-path=/etc/xkb" # default=$sysconfdir/xkb ($out/etc)
50 "-Dx-locale-root=${libX11.out}/share/X11/locale"
51 "-Denable-docs=true"
52 "-Denable-wayland=${lib.boolToString withWaylandTools}"
53 ];
54
55 doCheck = true;
56 preCheck = ''
57 patchShebangs ../test/
58 '';
59
60 passthru = {
61 tests.pkg-config = testers.hasPkgConfigModules {
62 package = finalAttrs.finalPackage;
63 };
64 };
65
66 meta = with lib; {
67 description = "Library to handle keyboard descriptions";
68 longDescription = ''
69 libxkbcommon is a keyboard keymap compiler and support library which
70 processes a reduced subset of keymaps as defined by the XKB (X Keyboard
71 Extension) specification. It also contains a module for handling Compose
72 and dead keys.
73 ''; # and a separate library for listing available keyboard layouts.
74 homepage = "https://xkbcommon.org";
75 changelog = "https://github.com/xkbcommon/libxkbcommon/blob/xkbcommon-${finalAttrs.version}/NEWS";
76 license = licenses.mit;
77 maintainers = with maintainers; [ primeos ttuegel ];
78 mainProgram = "xkbcli";
79 platforms = with platforms; unix;
80 pkgConfigModules = [
81 "xkbcommon"
82 "xkbcommon-x11"
83 "xkbregistry"
84 ];
85 };
86})