70 lines
2.3 KiB
Nix
70 lines
2.3 KiB
Nix
{
|
|
flake.modules.nixos.input =
|
|
{
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
hostInput = config.meta.host.input;
|
|
|
|
hasAnyConfiguredValue = attrs: lib.any (value: value != null) (lib.attrValues attrs);
|
|
libinputScrollMethodMap = {
|
|
edge = "edge";
|
|
"no-scroll" = "none";
|
|
"on-button-down" = "button";
|
|
"two-finger" = "twofinger";
|
|
};
|
|
libinputClickMethodMap = {
|
|
"button-areas" = "buttonareas";
|
|
clickfinger = "clickfinger";
|
|
};
|
|
|
|
hasMouseConfig = hasAnyConfiguredValue hostInput.mouse;
|
|
hasTouchpadConfig = hasAnyConfiguredValue hostInput.touchpad;
|
|
hasPointerConfig = hasMouseConfig || hasTouchpadConfig;
|
|
|
|
mouseConfig = lib.filterAttrs (_: value: value != null) {
|
|
accelProfile = hostInput.mouse.accelProfile;
|
|
accelSpeed =
|
|
if hostInput.mouse.accelSpeed == null then null else toString hostInput.mouse.accelSpeed;
|
|
leftHanded = hostInput.mouse.leftHanded;
|
|
middleEmulation = hostInput.mouse.middleEmulation;
|
|
naturalScrolling = hostInput.mouse.naturalScrolling;
|
|
scrollMethod =
|
|
if hostInput.mouse.scrollMethod == null then
|
|
null
|
|
else
|
|
libinputScrollMethodMap.${hostInput.mouse.scrollMethod};
|
|
};
|
|
|
|
touchpadConfig = lib.filterAttrs (_: value: value != null) {
|
|
accelProfile = hostInput.touchpad.accelProfile;
|
|
accelSpeed =
|
|
if hostInput.touchpad.accelSpeed == null then null else toString hostInput.touchpad.accelSpeed;
|
|
clickMethod =
|
|
if hostInput.touchpad.clickMethod == null then
|
|
null
|
|
else
|
|
libinputClickMethodMap.${hostInput.touchpad.clickMethod};
|
|
disableWhileTyping = hostInput.touchpad.disableWhileTyping;
|
|
leftHanded = hostInput.touchpad.leftHanded;
|
|
middleEmulation = hostInput.touchpad.middleEmulation;
|
|
naturalScrolling = hostInput.touchpad.naturalScrolling;
|
|
scrollMethod =
|
|
if hostInput.touchpad.scrollMethod == null then
|
|
null
|
|
else
|
|
libinputScrollMethodMap.${hostInput.touchpad.scrollMethod};
|
|
tapping = hostInput.touchpad.tapping;
|
|
};
|
|
in
|
|
{
|
|
services.libinput = lib.mkIf hasPointerConfig {
|
|
enable = true;
|
|
mouse = mouseConfig;
|
|
touchpad = touchpadConfig;
|
|
};
|
|
};
|
|
}
|