at 25.11-pre 2.3 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.persistent-evdev; 10 settingsFormat = pkgs.formats.json { }; 11 12 configFile = settingsFormat.generate "persistent-evdev-config" { 13 cache = "/var/cache/persistent-evdev"; 14 devices = lib.mapAttrs (virt: phys: "/dev/input/by-id/${phys}") cfg.devices; 15 }; 16in 17{ 18 options.services.persistent-evdev = { 19 enable = lib.mkEnableOption "virtual input devices that persist even if the backing device is hotplugged"; 20 21 devices = lib.mkOption { 22 default = { }; 23 type = with lib.types; attrsOf str; 24 description = '' 25 A set of virtual proxy device labels with backing physical device ids. 26 27 Physical devices should already exist in {file}`/dev/input/by-id/`. 28 Proxy devices will be automatically given a `uinput-` prefix. 29 30 See the [project page](https://github.com/aiberia/persistent-evdev#example-usage-with-libvirt) 31 for example configuration of virtual devices with libvirt 32 and remember to add `uinput-*` devices to the qemu 33 `cgroup_device_acl` list (see [](#opt-virtualisation.libvirtd.qemu.verbatimConfig)). 34 ''; 35 example = lib.literalExpression '' 36 { 37 persist-mouse0 = "usb-Logitech_G403_Prodigy_Gaming_Mouse_078738533531-event-if01"; 38 persist-mouse1 = "usb-Logitech_G403_Prodigy_Gaming_Mouse_078738533531-event-mouse"; 39 persist-mouse2 = "usb-Logitech_G403_Prodigy_Gaming_Mouse_078738533531-if01-event-kbd"; 40 persist-keyboard0 = "usb-Microsoft_Natural®_Ergonomic_Keyboard_4000-event-kbd"; 41 persist-keyboard1 = "usb-Microsoft_Natural®_Ergonomic_Keyboard_4000-if01-event-kbd"; 42 } 43 ''; 44 }; 45 }; 46 47 config = lib.mkIf cfg.enable { 48 49 systemd.services.persistent-evdev = { 50 documentation = [ "https://github.com/aiberia/persistent-evdev/blob/master/README.md" ]; 51 description = "Persistent evdev proxy"; 52 wantedBy = [ "multi-user.target" ]; 53 54 serviceConfig = { 55 Restart = "on-failure"; 56 ExecStart = "${pkgs.persistent-evdev}/bin/persistent-evdev.py ${configFile}"; 57 CacheDirectory = "persistent-evdev"; 58 }; 59 }; 60 61 services.udev.packages = [ pkgs.persistent-evdev ]; 62 }; 63 64 meta.maintainers = with lib.maintainers; [ lodi ]; 65}