From b282ad165a8c4c433a8cefd9e237d4260d0bbc1a Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Dec 2024 00:30:17 +0100 Subject: [PATCH 1/6] nixos/evremap: extend key type allow the key to be remapped start with BTN as well as KEY, to enable remapping of mouse buttons --- nixos/modules/services/misc/evremap.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/misc/evremap.nix b/nixos/modules/services/misc/evremap.nix index 9508955d8171..24832adba10a 100644 --- a/nixos/modules/services/misc/evremap.nix +++ b/nixos/modules/services/misc/evremap.nix @@ -8,8 +8,8 @@ let cfg = config.services.evremap; format = pkgs.formats.toml { }; - key = lib.types.strMatching "KEY_[[:upper:]]+" // { - description = "key ID prefixed with KEY_"; + key = lib.types.strMatching "(BTN|KEY)_[[:upper:]]+" // { + description = "key ID prefixed with BTN_ or KEY_"; }; mkKeyOption = From d7ad16e525c18f36e2ca193194dfba8b25774722 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Dec 2024 01:51:04 +0100 Subject: [PATCH 2/6] nixos/evremap: add option phys adds the optional attribute `phys` to uniquely identify a single device, if multiple devices share the same name --- nixos/modules/services/misc/evremap.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/services/misc/evremap.nix b/nixos/modules/services/misc/evremap.nix index 24832adba10a..1dd7310d73d7 100644 --- a/nixos/modules/services/misc/evremap.nix +++ b/nixos/modules/services/misc/evremap.nix @@ -63,6 +63,18 @@ in ''; }; + phys = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + example = "usb-0000:07:00.3-2.1.1/input0"; + description = '' + If you have multiple devices with the same name, you can optionally + specify this attribute. + + If available, the value will be printed when running `evremap list-devices` with elevated permissions. + ''; + }; + dual_role = lib.mkOption { type = lib.types.listOf dualRoleModule; default = [ ]; From d22eeb20ea4c7a6561682a9757c6184870ab5020 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 7 Dec 2024 03:41:35 +0100 Subject: [PATCH 3/6] nixos/evremap: fix toml config generation filter out attrsets with a `null` value as toml doesn't support it --- nixos/modules/services/misc/evremap.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/evremap.nix b/nixos/modules/services/misc/evremap.nix index 1dd7310d73d7..3d8fcf51e5ef 100644 --- a/nixos/modules/services/misc/evremap.nix +++ b/nixos/modules/services/misc/evremap.nix @@ -129,7 +129,7 @@ in description = "evremap - keyboard input remapper"; wantedBy = [ "multi-user.target" ]; - script = "${lib.getExe pkgs.evremap} remap ${format.generate "evremap.toml" cfg.settings}"; + script = "${lib.getExe pkgs.evremap} remap ${format.generate "evremap.toml" (lib.attrsets.filterAttrs (n: v: v != null) cfg.settings)}"; serviceConfig = { DynamicUser = true; From cee45b14e621b4acc76b5cc01681d84cf9e54c07 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 7 Dec 2024 05:10:25 +0100 Subject: [PATCH 4/6] nixos/evremap: use nixfmt --- nixos/modules/services/misc/evremap.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/misc/evremap.nix b/nixos/modules/services/misc/evremap.nix index 3d8fcf51e5ef..6fffc62f6eef 100644 --- a/nixos/modules/services/misc/evremap.nix +++ b/nixos/modules/services/misc/evremap.nix @@ -70,7 +70,7 @@ in description = '' If you have multiple devices with the same name, you can optionally specify this attribute. - + If available, the value will be printed when running `evremap list-devices` with elevated permissions. ''; }; @@ -129,7 +129,9 @@ in description = "evremap - keyboard input remapper"; wantedBy = [ "multi-user.target" ]; - script = "${lib.getExe pkgs.evremap} remap ${format.generate "evremap.toml" (lib.attrsets.filterAttrs (n: v: v != null) cfg.settings)}"; + script = "${lib.getExe pkgs.evremap} remap ${ + format.generate "evremap.toml" (lib.attrsets.filterAttrs (n: v: v != null) cfg.settings) + }"; serviceConfig = { DynamicUser = true; From e68ea6914dea5b038412c429ee347e06aaa52bb0 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 9 Dec 2024 19:10:13 +0100 Subject: [PATCH 5/6] nixos/evremap: incorporate changes from review --- nixos/modules/services/misc/evremap.nix | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/misc/evremap.nix b/nixos/modules/services/misc/evremap.nix index 6fffc62f6eef..a82719f89717 100644 --- a/nixos/modules/services/misc/evremap.nix +++ b/nixos/modules/services/misc/evremap.nix @@ -7,6 +7,8 @@ let cfg = config.services.evremap; format = pkgs.formats.toml { }; + settings = lib.attrsets.filterAttrs (n: v: v != null) cfg.settings; + configFile = format.generate "evremap.toml" settings; key = lib.types.strMatching "(BTN|KEY)_[[:upper:]]+" // { description = "key ID prefixed with BTN_ or KEY_"; @@ -68,10 +70,10 @@ in default = null; example = "usb-0000:07:00.3-2.1.1/input0"; description = '' - If you have multiple devices with the same name, you can optionally - specify this attribute. + The physical device name to listen on. - If available, the value will be printed when running `evremap list-devices` with elevated permissions. + This attribute may be specified to disambiguate multiple devices with the same device name. + The physical device names of each device can be obtained by running `evremap list-devices` with elevated permissions. ''; }; @@ -129,9 +131,7 @@ in description = "evremap - keyboard input remapper"; wantedBy = [ "multi-user.target" ]; - script = "${lib.getExe pkgs.evremap} remap ${ - format.generate "evremap.toml" (lib.attrsets.filterAttrs (n: v: v != null) cfg.settings) - }"; + script = "${lib.getExe pkgs.evremap} remap ${configFile}"; serviceConfig = { DynamicUser = true; From 6a5dc7cbd5a711815eb72a9d2815bbc4d238153f Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 6 Dec 2024 01:51:04 +0100 Subject: [PATCH 6/6] nixos/evremap: add option phys adds the optional attribute `phys` to uniquely identify a single device, if multiple devices share the same name nixos/evremap: fix toml config generation filter out attrsets with a `null` value as toml doesn't support it nixos/evremap: use nixfmt nixos/evremap: incorporate changes from review --- nixos/modules/services/misc/evremap.nix | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/evremap.nix b/nixos/modules/services/misc/evremap.nix index 24832adba10a..a82719f89717 100644 --- a/nixos/modules/services/misc/evremap.nix +++ b/nixos/modules/services/misc/evremap.nix @@ -7,6 +7,8 @@ let cfg = config.services.evremap; format = pkgs.formats.toml { }; + settings = lib.attrsets.filterAttrs (n: v: v != null) cfg.settings; + configFile = format.generate "evremap.toml" settings; key = lib.types.strMatching "(BTN|KEY)_[[:upper:]]+" // { description = "key ID prefixed with BTN_ or KEY_"; @@ -63,6 +65,18 @@ in ''; }; + phys = lib.mkOption { + type = lib.types.nullOr lib.types.str; + default = null; + example = "usb-0000:07:00.3-2.1.1/input0"; + description = '' + The physical device name to listen on. + + This attribute may be specified to disambiguate multiple devices with the same device name. + The physical device names of each device can be obtained by running `evremap list-devices` with elevated permissions. + ''; + }; + dual_role = lib.mkOption { type = lib.types.listOf dualRoleModule; default = [ ]; @@ -117,7 +131,7 @@ in description = "evremap - keyboard input remapper"; wantedBy = [ "multi-user.target" ]; - script = "${lib.getExe pkgs.evremap} remap ${format.generate "evremap.toml" cfg.settings}"; + script = "${lib.getExe pkgs.evremap} remap ${configFile}"; serviceConfig = { DynamicUser = true;