diff options
author | Timo Kaufmann <timokau@zoho.com> | 2022-03-07 18:51:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-07 18:51:08 +0100 |
commit | 94ea3a88999a92e9498584e728d5ac7b9e9f2882 (patch) | |
tree | 4fd6e0f735a6e2d66262eedf99b35a63daeeb81c /nixos | |
parent | 75ea3ea9b8c0beecc5db8ef8c429d9354573d776 (diff) | |
parent | 064362042091a21a75a682d7d9d0811e0033f73b (diff) | |
download | nixlib-94ea3a88999a92e9498584e728d5ac7b9e9f2882.tar nixlib-94ea3a88999a92e9498584e728d5ac7b9e9f2882.tar.gz nixlib-94ea3a88999a92e9498584e728d5ac7b9e9f2882.tar.bz2 nixlib-94ea3a88999a92e9498584e728d5ac7b9e9f2882.tar.lz nixlib-94ea3a88999a92e9498584e728d5ac7b9e9f2882.tar.xz nixlib-94ea3a88999a92e9498584e728d5ac7b9e9f2882.tar.zst nixlib-94ea3a88999a92e9498584e728d5ac7b9e9f2882.zip |
Merge pull request #160777 from LunNova/improve-input-remapper-module
nixos/input-remapper: Fix missing [], add more options, add test
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/misc/input-remapper.nix | 27 | ||||
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/input-remapper.nix | 52 |
3 files changed, 67 insertions, 13 deletions
diff --git a/nixos/modules/services/misc/input-remapper.nix b/nixos/modules/services/misc/input-remapper.nix index c2da0d616a31..f5fb2bf53086 100644 --- a/nixos/modules/services/misc/input-remapper.nix +++ b/nixos/modules/services/misc/input-remapper.nix @@ -7,23 +7,24 @@ let cfg = config.services.input-remapper; in options = { services.input-remapper = { enable = mkEnableOption "input-remapper, an easy to use tool to change the mapping of your input device buttons."; - package = mkOption { - type = types.package; - default = pkgs.input-remapper; - defaultText = literalExpression "pkgs.input-remapper"; - description = '' - The input-remapper package to use. - ''; + package = options.mkPackageOption pkgs "input-remapper" { }; + enableUdevRules = mkEnableOption "udev rules added by input-remapper to handle hotplugged devices. Currently disabled by default due to https://github.com/sezanzeb/input-remapper/issues/140"; + serviceWantedBy = mkOption { + default = [ "graphical.target" ]; + example = [ "multi-user.target" ]; + type = types.listOf types.str; + description = "Specifies the WantedBy setting for the input-remapper service."; }; }; }; config = mkIf cfg.enable { - # FIXME: udev rule hangs sometimes when lots of devices connected, so let's not use it - # config.services.udev.packages = mapper-pkg; - services.dbus.packages = cfg.package; - systemd.packages = cfg.package; - environment.systemPackages = cfg.package; - systemd.services.input-remapper.wantedBy = [ "graphical.target" ]; + services.udev.packages = mkIf cfg.enableUdevRules [ cfg.package ]; + services.dbus.packages = [ cfg.package ]; + systemd.packages = [ cfg.package ]; + environment.systemPackages = [ cfg.package ]; + systemd.services.input-remapper.wantedBy = cfg.serviceWantedBy; }; + + meta.maintainers = with lib.maintainers; [ LunNova ]; } diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 342e8f461b57..15b54cd9fe1d 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -224,6 +224,7 @@ in initrd-network-ssh = handleTest ./initrd-network-ssh {}; initrdNetwork = handleTest ./initrd-network.nix {}; initrd-secrets = handleTest ./initrd-secrets.nix {}; + input-remapper = handleTest ./input-remapper.nix {}; inspircd = handleTest ./inspircd.nix {}; installer = handleTest ./installer.nix {}; invoiceplane = handleTest ./invoiceplane.nix {}; diff --git a/nixos/tests/input-remapper.nix b/nixos/tests/input-remapper.nix new file mode 100644 index 000000000000..f692564caa57 --- /dev/null +++ b/nixos/tests/input-remapper.nix @@ -0,0 +1,52 @@ +import ./make-test-python.nix ({ pkgs, ... }: + + { + name = "input-remapper"; + meta = { + maintainers = with pkgs.lib.maintainers; [ LunNova ]; + }; + + machine = { config, ... }: + let user = config.users.users.sybil; in + { + imports = [ + ./common/user-account.nix + ./common/x11.nix + ]; + + services.xserver.enable = true; + services.input-remapper.enable = true; + users.users.sybil = { isNormalUser = true; group = "wheel"; }; + test-support.displayManager.auto.user = user.name; + # workaround for pkexec not working in the test environment + # Error creating textual authentication agent: + # Error opening current controlling terminal for the process (`/dev/tty'): + # No such device or address + # passwordless pkexec with polkit module also doesn't work + # to allow the program to run, we replace pkexec with sudo + # and turn on passwordless sudo + # this is not correct in general but good enough for this test + security.sudo = { enable = true; wheelNeedsPassword = false; }; + security.wrappers.pkexec = pkgs.lib.mkForce + { + setuid = true; + owner = "root"; + group = "root"; + source = "${pkgs.sudo}/bin/sudo"; + }; + }; + + enableOCR = true; + + testScript = { nodes, ... }: '' + start_all() + machine.wait_for_x() + + machine.succeed("systemctl status input-remapper.service") + machine.execute("su - sybil -c input-remapper-gtk >&2 &") + + machine.wait_for_text("Input Remapper") + machine.wait_for_text("Preset") + machine.wait_for_text("Change Key") + ''; + }) |