diff --git a/nixos/modules/services/x11/hardware/libinput.nix b/nixos/modules/services/x11/hardware/libinput.nix
index e2fb7d0918e3..efdb7c61dfae 100644
--- a/nixos/modules/services/x11/hardware/libinput.nix
+++ b/nixos/modules/services/x11/hardware/libinput.nix
@@ -13,7 +13,7 @@ let cfg = config.services.xserver.libinput;
example = "/dev/input/event0";
description =
''
- Path for ${deviceType} device. Set to null to apply to any
+ Path for ${deviceType} device. Set to null to apply to any
auto-detected ${deviceType}.
'';
};
@@ -24,8 +24,8 @@ let cfg = config.services.xserver.libinput;
example = "flat";
description =
''
- Sets the pointer acceleration profile to the given profile.
- Permitted values are adaptive, flat.
+ Sets the pointer acceleration profile to the given profile.
+ Permitted values are adaptive, flat.
Not all devices support this option or all profiles.
If a profile is unsupported, the default profile for this is used.
flat: Pointer motion is accelerated by a constant
@@ -38,12 +38,14 @@ let cfg = config.services.xserver.libinput;
accelSpeed = mkOption {
type = types.nullOr types.str;
default = null;
+ example = "-0.5";
description = "Cursor acceleration (how fast speed increases from minSpeed to maxSpeed).";
};
buttonMapping = mkOption {
type = types.nullOr types.str;
default = null;
+ example = "1 6 3 4 5 0 7";
description =
''
Sets the logical button mapping for this device, see XSetPointerMapping(3). The string must
@@ -58,9 +60,10 @@ let cfg = config.services.xserver.libinput;
calibrationMatrix = mkOption {
type = types.nullOr types.str;
default = null;
+ example = "0.5 0 0 0 0.8 0.1 0 0 1";
description =
''
- A string of 9 space-separated floating point numbers. Sets the calibration matrix to the
+ A string of 9 space-separated floating point numbers. Sets the calibration matrix to the
3x3 matrix where the first row is (abc), the second row is (def) and the third row is (ghi).
'';
};
@@ -68,6 +71,7 @@ let cfg = config.services.xserver.libinput;
clickMethod = mkOption {
type = types.nullOr (types.enum [ "none" "buttonareas" "clickfinger" ]);
default = null;
+ example = "buttonareas";
description =
''
Enables a click method. Permitted values are none,
@@ -166,8 +170,9 @@ let cfg = config.services.xserver.libinput;
transformationMatrix = mkOption {
type = types.nullOr types.str;
default = null;
+ example = "0.5 0 0 0 0.8 0.1 0 0 1";
description = ''
- A string of 9 space-separated floating point numbers. Sets the transformation matrix to
+ A string of 9 space-separated floating point numbers. Sets the transformation matrix to
the 3x3 matrix where the first row is (abc), the second row is (def) and the third row is (ghi).
'';
};
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 985dbd3b6767..a74792d3d2eb 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -228,9 +228,10 @@ in
kubernetes = handleTestOn ["x86_64-linux"] ./kubernetes {};
latestKernel.login = handleTest ./login.nix { latestKernel = true; };
leaps = handleTest ./leaps.nix {};
+ libinput = handleTest ./libinput.nix {};
libreddit = handleTest ./libreddit.nix {};
- lidarr = handleTest ./lidarr.nix {};
libreswan = handleTest ./libreswan.nix {};
+ lidarr = handleTest ./lidarr.nix {};
lightdm = handleTest ./lightdm.nix {};
limesurvey = handleTest ./limesurvey.nix {};
litestream = handleTest ./litestream.nix {};
diff --git a/nixos/tests/libinput.nix b/nixos/tests/libinput.nix
new file mode 100644
index 000000000000..2f84aaadcd0b
--- /dev/null
+++ b/nixos/tests/libinput.nix
@@ -0,0 +1,38 @@
+import ./make-test-python.nix ({ ... }:
+
+{
+ name = "libinput";
+
+ machine = { ... }:
+ {
+ imports = [
+ ./common/x11.nix
+ ./common/user-account.nix
+ ];
+
+ test-support.displayManager.auto.user = "alice";
+
+ services.xserver.libinput = {
+ enable = true;
+ mouse = {
+ naturalScrolling = true;
+ leftHanded = true;
+ middleEmulation = false;
+ horizontalScrolling = false;
+ };
+ };
+ };
+
+ testScript = ''
+ def expect_xserver_option(option, value):
+ machine.succeed(f"""cat /var/log/X.0.log | grep -F 'Option "{option}" "{value}"'""")
+
+ machine.start()
+ machine.wait_for_x()
+ machine.succeed("""cat /var/log/X.0.log | grep -F "Using input driver 'libinput'" """)
+ expect_xserver_option("NaturalScrolling", "on")
+ expect_xserver_option("LeftHanded", "on")
+ expect_xserver_option("MiddleEmulation", "off")
+ expect_xserver_option("HorizontalScrolling", "off")
+ '';
+})
diff --git a/pkgs/development/libraries/libinput/default.nix b/pkgs/development/libraries/libinput/default.nix
index baee67cb826d..54843486e137 100644
--- a/pkgs/development/libraries/libinput/default.nix
+++ b/pkgs/development/libraries/libinput/default.nix
@@ -3,6 +3,7 @@
, documentationSupport ? false, doxygen, graphviz # Documentation
, eventGUISupport ? false, cairo, glib, gtk3 # GUI event viewer support
, testsSupport ? false, check, valgrind, python3
+, nixosTests
}:
let
@@ -76,6 +77,10 @@ stdenv.mkDerivation rec {
doCheck = testsSupport && stdenv.hostPlatform == stdenv.buildPlatform;
+ passthru.tests = {
+ libinput-module = nixosTests.libinput;
+ };
+
meta = with lib; {
description = "Handles input devices in Wayland compositors and provides a generic X.Org input driver";
homepage = "https://www.freedesktop.org/wiki/Software/libinput/";