Format files

This commit is contained in:
Vili Sinervä 2024-07-20 17:35:00 +03:00
parent 26b6e53956
commit f4356fc733
No known key found for this signature in database
GPG key ID: DF8FEAF54EFAC996
4 changed files with 453 additions and 339 deletions

View file

@ -1,9 +1,4 @@
{ { config, pkgs, ... }:
config,
pkgs,
lib,
...
}:
{ {
networking = { networking = {
hostName = "helium"; hostName = "helium";

View file

@ -1,9 +1,4 @@
{ { config, pkgs, ... }:
config,
pkgs,
lib,
...
}:
{ {
networking.hostName = "lithium"; networking.hostName = "lithium";

View file

@ -1,9 +1,4 @@
{ { config, pkgs, ... }:
config,
pkgs,
lib,
...
}:
let let
SSID = "ENTER_SSID"; SSID = "ENTER_SSID";
SSIDpassword = "ENTER_PASSWORD"; SSIDpassword = "ENTER_PASSWORD";

View file

@ -1,8 +1,14 @@
{ config, lib, pkgs, ... }: {
config,
lib,
pkgs,
...
}:
with lib; with lib;
let cfg = config.services.libinput; let
cfg = config.services.libinput;
xorgBool = v: if v then "on" else "off"; xorgBool = v: if v then "on" else "off";
@ -18,7 +24,11 @@ let cfg = config.services.libinput;
}; };
accelProfile = mkOption { accelProfile = mkOption {
type = types.enum [ "flat" "adaptive" "custom" ]; type = types.enum [
"flat"
"adaptive"
"custom"
];
default = "adaptive"; default = "adaptive";
example = "flat"; example = "flat";
description = '' description = ''
@ -49,7 +59,12 @@ let cfg = config.services.libinput;
accelPointsFallback = mkOption { accelPointsFallback = mkOption {
type = types.nullOr (types.listOf types.number); type = types.nullOr (types.listOf types.number);
default = null; default = null;
example = [ 0.0 1.0 2.4 2.5 ]; example = [
0.0
1.0
2.4
2.5
];
description = '' description = ''
Sets the points of the fallback acceleration function. The value must be a list of Sets the points of the fallback acceleration function. The value must be a list of
floating point non-negative numbers. This only applies to the custom profile. floating point non-negative numbers. This only applies to the custom profile.
@ -59,7 +74,12 @@ let cfg = config.services.libinput;
accelPointsMotion = mkOption { accelPointsMotion = mkOption {
type = types.nullOr (types.listOf types.number); type = types.nullOr (types.listOf types.number);
default = null; default = null;
example = [ 0.0 1.0 2.4 2.5 ]; example = [
0.0
1.0
2.4
2.5
];
description = '' description = ''
Sets the points of the (pointer) motion acceleration function. The value must be a Sets the points of the (pointer) motion acceleration function. The value must be a
list of floating point non-negative numbers. This only applies to the custom profile. list of floating point non-negative numbers. This only applies to the custom profile.
@ -69,7 +89,12 @@ let cfg = config.services.libinput;
accelPointsScroll = mkOption { accelPointsScroll = mkOption {
type = types.nullOr (types.listOf types.number); type = types.nullOr (types.listOf types.number);
default = null; default = null;
example = [ 0.0 1.0 2.4 2.5 ]; example = [
0.0
1.0
2.4
2.5
];
description = '' description = ''
Sets the points of the scroll acceleration function. The value must be a list of Sets the points of the scroll acceleration function. The value must be a list of
floating point non-negative numbers. This only applies to the custom profile. floating point non-negative numbers. This only applies to the custom profile.
@ -134,7 +159,13 @@ let cfg = config.services.libinput;
}; };
clickMethod = mkOption { clickMethod = mkOption {
type = types.nullOr (types.enum [ "none" "buttonareas" "clickfinger" ]); type = types.nullOr (
types.enum [
"none"
"buttonareas"
"clickfinger"
]
);
default = null; default = null;
example = "buttonareas"; example = "buttonareas";
description = '' description = ''
@ -177,7 +208,12 @@ let cfg = config.services.libinput;
}; };
scrollMethod = mkOption { scrollMethod = mkOption {
type = types.enum [ "twofinger" "edge" "button" "none" ]; type = types.enum [
"twofinger"
"edge"
"button"
"none"
];
default = "twofinger"; default = "twofinger";
example = "edge"; example = "edge";
description = '' description = ''
@ -197,7 +233,11 @@ let cfg = config.services.libinput;
}; };
sendEventsMode = mkOption { sendEventsMode = mkOption {
type = types.enum [ "disabled" "enabled" "disabled-on-external-mouse" ]; type = types.enum [
"disabled"
"enabled"
"disabled-on-external-mouse"
];
default = "enabled"; default = "enabled";
example = "disabled"; example = "disabled";
description = '' description = ''
@ -215,7 +255,12 @@ let cfg = config.services.libinput;
}; };
tappingButtonMap = mkOption { tappingButtonMap = mkOption {
type = types.nullOr (types.enum [ "lrm" "lmr" ]); type = types.nullOr (
types.enum [
"lrm"
"lmr"
]
);
default = null; default = null;
description = '' description = ''
Set the button mapping for 1/2/3-finger taps to left/right/middle or left/middle/right, respectively. Set the button mapping for 1/2/3-finger taps to left/right/middle or left/middle/right, respectively.
@ -253,8 +298,7 @@ let cfg = config.services.libinput;
additionalOptions = mkOption { additionalOptions = mkOption {
type = types.lines; type = types.lines;
default = ""; default = "";
example = example = ''
''
Option "DragLockButtons" "L1 B1 L2 B2" Option "DragLockButtons" "L1 B1 L2 B2"
''; '';
description = '' description = ''
@ -271,34 +315,78 @@ let cfg = config.services.libinput;
MatchIs${matchIs} "${xorgBool true}" MatchIs${matchIs} "${xorgBool true}"
${optionalString (cfg.${deviceType}.dev != null) ''MatchDevicePath "${cfg.${deviceType}.dev}"''} ${optionalString (cfg.${deviceType}.dev != null) ''MatchDevicePath "${cfg.${deviceType}.dev}"''}
Option "AccelProfile" "${cfg.${deviceType}.accelProfile}" Option "AccelProfile" "${cfg.${deviceType}.accelProfile}"
${optionalString (cfg.${deviceType}.accelSpeed != null) ''Option "AccelSpeed" "${cfg.${deviceType}.accelSpeed}"''} ${optionalString (
${optionalString (cfg.${deviceType}.accelPointsFallback != null) ''Option "AccelPointsFallback" "${toString cfg.${deviceType}.accelPointsFallback}"''} cfg.${deviceType}.accelSpeed != null
${optionalString (cfg.${deviceType}.accelPointsMotion != null) ''Option "AccelPointsMotion" "${toString cfg.${deviceType}.accelPointsMotion}"''} ) ''Option "AccelSpeed" "${cfg.${deviceType}.accelSpeed}"''}
${optionalString (cfg.${deviceType}.accelPointsScroll != null) ''Option "AccelPointsScroll" "${toString cfg.${deviceType}.accelPointsScroll}"''} ${optionalString (cfg.${deviceType}.accelPointsFallback != null)
${optionalString (cfg.${deviceType}.accelStepFallback != null) ''Option "AccelStepFallback" "${toString cfg.${deviceType}.accelStepFallback}"''} ''Option "AccelPointsFallback" "${toString cfg.${deviceType}.accelPointsFallback}"''
${optionalString (cfg.${deviceType}.accelStepMotion != null) ''Option "AccelStepMotion" "${toString cfg.${deviceType}.accelStepMotion}"''} }
${optionalString (cfg.${deviceType}.accelStepScroll != null) ''Option "AccelStepScroll" "${toString cfg.${deviceType}.accelStepScroll}"''} ${optionalString (cfg.${deviceType}.accelPointsMotion != null)
${optionalString (cfg.${deviceType}.buttonMapping != null) ''Option "ButtonMapping" "${cfg.${deviceType}.buttonMapping}"''} ''Option "AccelPointsMotion" "${toString cfg.${deviceType}.accelPointsMotion}"''
${optionalString (cfg.${deviceType}.calibrationMatrix != null) ''Option "CalibrationMatrix" "${cfg.${deviceType}.calibrationMatrix}"''} }
${optionalString (cfg.${deviceType}.transformationMatrix != null) ''Option "TransformationMatrix" "${cfg.${deviceType}.transformationMatrix}"''} ${optionalString (cfg.${deviceType}.accelPointsScroll != null)
${optionalString (cfg.${deviceType}.clickMethod != null) ''Option "ClickMethod" "${cfg.${deviceType}.clickMethod}"''} ''Option "AccelPointsScroll" "${toString cfg.${deviceType}.accelPointsScroll}"''
}
${optionalString (cfg.${deviceType}.accelStepFallback != null)
''Option "AccelStepFallback" "${toString cfg.${deviceType}.accelStepFallback}"''
}
${optionalString (cfg.${deviceType}.accelStepMotion != null)
''Option "AccelStepMotion" "${toString cfg.${deviceType}.accelStepMotion}"''
}
${optionalString (cfg.${deviceType}.accelStepScroll != null)
''Option "AccelStepScroll" "${toString cfg.${deviceType}.accelStepScroll}"''
}
${optionalString (cfg.${deviceType}.buttonMapping != null)
''Option "ButtonMapping" "${cfg.${deviceType}.buttonMapping}"''
}
${optionalString (cfg.${deviceType}.calibrationMatrix != null)
''Option "CalibrationMatrix" "${cfg.${deviceType}.calibrationMatrix}"''
}
${optionalString (
cfg.${deviceType}.transformationMatrix != null
) ''Option "TransformationMatrix" "${cfg.${deviceType}.transformationMatrix}"''}
${optionalString (
cfg.${deviceType}.clickMethod != null
) ''Option "ClickMethod" "${cfg.${deviceType}.clickMethod}"''}
Option "LeftHanded" "${xorgBool cfg.${deviceType}.leftHanded}" Option "LeftHanded" "${xorgBool cfg.${deviceType}.leftHanded}"
Option "MiddleEmulation" "${xorgBool cfg.${deviceType}.middleEmulation}" Option "MiddleEmulation" "${xorgBool cfg.${deviceType}.middleEmulation}"
Option "NaturalScrolling" "${xorgBool cfg.${deviceType}.naturalScrolling}" Option "NaturalScrolling" "${xorgBool cfg.${deviceType}.naturalScrolling}"
${optionalString (cfg.${deviceType}.scrollButton != null) ''Option "ScrollButton" "${toString cfg.${deviceType}.scrollButton}"''} ${optionalString (cfg.${deviceType}.scrollButton != null)
''Option "ScrollButton" "${toString cfg.${deviceType}.scrollButton}"''
}
Option "ScrollMethod" "${cfg.${deviceType}.scrollMethod}" Option "ScrollMethod" "${cfg.${deviceType}.scrollMethod}"
Option "HorizontalScrolling" "${xorgBool cfg.${deviceType}.horizontalScrolling}" Option "HorizontalScrolling" "${xorgBool cfg.${deviceType}.horizontalScrolling}"
Option "SendEventsMode" "${cfg.${deviceType}.sendEventsMode}" Option "SendEventsMode" "${cfg.${deviceType}.sendEventsMode}"
Option "Tapping" "${xorgBool cfg.${deviceType}.tapping}" Option "Tapping" "${xorgBool cfg.${deviceType}.tapping}"
${optionalString (cfg.${deviceType}.tappingButtonMap != null) ''Option "TappingButtonMap" "${cfg.${deviceType}.tappingButtonMap}"''} ${optionalString (cfg.${deviceType}.tappingButtonMap != null)
''Option "TappingButtonMap" "${cfg.${deviceType}.tappingButtonMap}"''
}
Option "TappingDragLock" "${xorgBool cfg.${deviceType}.tappingDragLock}" Option "TappingDragLock" "${xorgBool cfg.${deviceType}.tappingDragLock}"
Option "DisableWhileTyping" "${xorgBool cfg.${deviceType}.disableWhileTyping}" Option "DisableWhileTyping" "${xorgBool cfg.${deviceType}.disableWhileTyping}"
${cfg.${deviceType}.additionalOptions} ${cfg.${deviceType}.additionalOptions}
''; '';
in { in
{
imports = imports =
(map (option: mkRenamedOptionModule ([ "services" "xserver" "libinput" option ]) [ "services" "libinput" "touchpad" option ]) [ (map
(
option:
mkRenamedOptionModule
([
"services"
"xserver"
"libinput"
option
])
[
"services"
"libinput"
"touchpad"
option
]
)
[
"accelProfile" "accelProfile"
"accelSpeed" "accelSpeed"
"buttonMapping" "buttonMapping"
@ -317,10 +405,48 @@ in {
"transformationMatrix" "transformationMatrix"
"disableWhileTyping" "disableWhileTyping"
"additionalOptions" "additionalOptions"
]) ++ [ ]
(mkRenamedOptionModule [ "services" "xserver" "libinput" "enable" ] [ "services" "libinput" "enable" ]) )
(mkRenamedOptionModule [ "services" "xserver" "libinput" "mouse" ] [ "services" "libinput" "mouse" ]) ++ [
(mkRenamedOptionModule [ "services" "xserver" "libinput" "touchpad" ] [ "services" "libinput" "touchpad" ]) (mkRenamedOptionModule
[
"services"
"xserver"
"libinput"
"enable"
]
[
"services"
"libinput"
"enable"
]
)
(mkRenamedOptionModule
[
"services"
"xserver"
"libinput"
"mouse"
]
[
"services"
"libinput"
"mouse"
]
)
(mkRenamedOptionModule
[
"services"
"xserver"
"libinput"
"touchpad"
]
[
"services"
"libinput"
"touchpad"
]
)
]; ];
options = { options = {
@ -335,7 +461,6 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.xserver.modules = [ pkgs.xorg.xf86inputlibinput ]; services.xserver.modules = [ pkgs.xorg.xf86inputlibinput ];
@ -343,8 +468,10 @@ in {
environment.systemPackages = [ pkgs.xorg.xf86inputlibinput ]; environment.systemPackages = [ pkgs.xorg.xf86inputlibinput ];
environment.etc = environment.etc =
let cfgPath = "X11/xorg.conf.d/40-libinput.conf"; let
in { cfgPath = "X11/xorg.conf.d/40-libinput.conf";
in
{
${cfgPath} = { ${cfgPath} = {
source = pkgs.xorg.xf86inputlibinput.out + "/share/" + cfgPath; source = pkgs.xorg.xf86inputlibinput.out + "/share/" + cfgPath;
}; };
@ -359,10 +486,12 @@ in {
assertions = [ assertions = [
# already present in synaptics.nix # already present in synaptics.nix
/* { /*
{
assertion = !config.services.xserver.synaptics.enable; assertion = !config.services.xserver.synaptics.enable;
message = "Synaptics and libinput are incompatible, you cannot enable both (in services.xserver)."; message = "Synaptics and libinput are incompatible, you cannot enable both (in services.xserver).";
} */ }
*/
]; ];
}; };