mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-26 23:54:01 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
109 lines
3.0 KiB
Nix
109 lines
3.0 KiB
Nix
{ config, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
{
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
hardware.trackpoint = {
|
|
|
|
enable = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Enable sensitivity and speed configuration for trackpoints.
|
|
'';
|
|
};
|
|
|
|
sensitivity = mkOption {
|
|
default = 128;
|
|
example = 255;
|
|
type = types.int;
|
|
description = lib.mdDoc ''
|
|
Configure the trackpoint sensitivity. By default, the kernel
|
|
configures 128.
|
|
'';
|
|
};
|
|
|
|
speed = mkOption {
|
|
default = 97;
|
|
example = 255;
|
|
type = types.int;
|
|
description = lib.mdDoc ''
|
|
Configure the trackpoint speed. By default, the kernel
|
|
configures 97.
|
|
'';
|
|
};
|
|
|
|
emulateWheel = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Enable scrolling while holding the middle mouse button.
|
|
'';
|
|
};
|
|
|
|
fakeButtons = mkOption {
|
|
default = false;
|
|
type = types.bool;
|
|
description = lib.mdDoc ''
|
|
Switch to "bare" PS/2 mouse support in case Trackpoint buttons are not recognized
|
|
properly. This can happen for example on models like the L430, T450, T450s, on
|
|
which the Trackpoint buttons are actually a part of the Synaptics touchpad.
|
|
'';
|
|
};
|
|
|
|
device = mkOption {
|
|
default = "TPPS/2 IBM TrackPoint";
|
|
type = types.str;
|
|
description = lib.mdDoc ''
|
|
The device name of the trackpoint. You can check with xinput.
|
|
Some newer devices (example x1c6) use "TPPS/2 Elan TrackPoint".
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
###### implementation
|
|
|
|
config =
|
|
let cfg = config.hardware.trackpoint; in
|
|
mkMerge [
|
|
(mkIf cfg.enable {
|
|
services.udev.extraRules =
|
|
''
|
|
ACTION=="add|change", SUBSYSTEM=="input", ATTR{name}=="${cfg.device}", ATTR{device/speed}="${toString cfg.speed}", ATTR{device/sensitivity}="${toString cfg.sensitivity}"
|
|
'';
|
|
|
|
system.activationScripts.trackpoint =
|
|
''
|
|
${config.systemd.package}/bin/udevadm trigger --attr-match=name="${cfg.device}"
|
|
'';
|
|
})
|
|
|
|
(mkIf (cfg.emulateWheel) {
|
|
services.xserver.inputClassSections = [
|
|
''
|
|
Identifier "Trackpoint Wheel Emulation"
|
|
MatchProduct "${if cfg.fakeButtons then "PS/2 Generic Mouse" else "ETPS/2 Elantech TrackPoint|Elantech PS/2 TrackPoint|TPPS/2 IBM TrackPoint|DualPoint Stick|Synaptics Inc. Composite TouchPad / TrackPoint|ThinkPad USB Keyboard with TrackPoint|USB Trackpoint pointing device|Composite TouchPad / TrackPoint|${cfg.device}"}"
|
|
MatchDevicePath "/dev/input/event*"
|
|
Option "EmulateWheel" "true"
|
|
Option "EmulateWheelButton" "2"
|
|
Option "Emulate3Buttons" "false"
|
|
Option "XAxisMapping" "6 7"
|
|
Option "YAxisMapping" "4 5"
|
|
''
|
|
];
|
|
})
|
|
|
|
(mkIf cfg.fakeButtons {
|
|
boot.extraModprobeConfig = "options psmouse proto=bare";
|
|
})
|
|
];
|
|
}
|