Merge pull request #163226 from lodi/persistent-evdev

persistent-evdev: init at unstable-2022-01-14

authored by Sandro and committed by GitHub be96e241 cf68deab

+115
+9
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
··· 62 <link xlink:href="options.html#opt-services.infnoise.enable">services.infnoise</link>. 63 </para> 64 </listitem> 65 </itemizedlist> 66 </section> 67 <section xml:id="sec-release-22.11-incompatibilities">
··· 62 <link xlink:href="options.html#opt-services.infnoise.enable">services.infnoise</link>. 63 </para> 64 </listitem> 65 + <listitem> 66 + <para> 67 + <link xlink:href="https://github.com/aiberia/persistent-evdev">persistent-evdev</link>, 68 + a daemon to add virtual proxy devices that mirror a physical 69 + input device but persist even if the underlying hardware is 70 + hot-plugged. Available as 71 + <link linkend="opt-services.persistent-evdev.enable">services.persistent-evdev</link>. 72 + </para> 73 + </listitem> 74 </itemizedlist> 75 </section> 76 <section xml:id="sec-release-22.11-incompatibilities">
+1
nixos/doc/manual/release-notes/rl-2211.section.md
··· 29 30 - [infnoise](https://github.com/leetronics/infnoise), a hardware True Random Number Generator dongle. 31 Available as [services.infnoise](options.html#opt-services.infnoise.enable). 32 33 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> 34
··· 29 30 - [infnoise](https://github.com/leetronics/infnoise), a hardware True Random Number Generator dongle. 31 Available as [services.infnoise](options.html#opt-services.infnoise.enable). 32 + - [persistent-evdev](https://github.com/aiberia/persistent-evdev), a daemon to add virtual proxy devices that mirror a physical input device but persist even if the underlying hardware is hot-plugged. Available as [services.persistent-evdev](#opt-services.persistent-evdev.enable). 33 34 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> 35
+1
nixos/modules/module-list.nix
··· 606 ./services/misc/packagekit.nix 607 ./services/misc/paperless.nix 608 ./services/misc/parsoid.nix 609 ./services/misc/plex.nix 610 ./services/misc/plikd.nix 611 ./services/misc/podgrab.nix
··· 606 ./services/misc/packagekit.nix 607 ./services/misc/paperless.nix 608 ./services/misc/parsoid.nix 609 + ./services/misc/persistent-evdev.nix 610 ./services/misc/plex.nix 611 ./services/misc/plikd.nix 612 ./services/misc/podgrab.nix
+60
nixos/modules/services/misc/persistent-evdev.nix
···
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + let 4 + cfg = config.services.persistent-evdev; 5 + settingsFormat = pkgs.formats.json {}; 6 + 7 + configFile = settingsFormat.generate "persistent-evdev-config" { 8 + cache = "/var/cache/persistent-evdev"; 9 + devices = lib.mapAttrs (virt: phys: "/dev/input/by-id/${phys}") cfg.devices; 10 + }; 11 + in 12 + { 13 + options.services.persistent-evdev = { 14 + enable = lib.mkEnableOption "virtual input devices that persist even if the backing device is hotplugged"; 15 + 16 + devices = lib.mkOption { 17 + default = {}; 18 + type = with lib.types; attrsOf str; 19 + description = '' 20 + A set of virtual proxy device labels with backing physical device ids. 21 + 22 + Physical devices should already exist in <filename class="devicefile">/dev/input/by-id/</filename>. 23 + Proxy devices will be automatically given a <literal>uinput-</literal> prefix. 24 + 25 + See the <link xlink:href="https://github.com/aiberia/persistent-evdev#example-usage-with-libvirt"> 26 + project page</link> for example configuration of virtual devices with libvirt 27 + and remember to add <literal>uinput-*</literal> devices to the qemu 28 + <literal>cgroup_device_acl</literal> list (see <xref linkend="opt-virtualisation.libvirtd.qemu.verbatimConfig"/>). 29 + ''; 30 + example = lib.literalExpression '' 31 + { 32 + persist-mouse0 = "usb-Logitech_G403_Prodigy_Gaming_Mouse_078738533531-event-if01"; 33 + persist-mouse1 = "usb-Logitech_G403_Prodigy_Gaming_Mouse_078738533531-event-mouse"; 34 + persist-mouse2 = "usb-Logitech_G403_Prodigy_Gaming_Mouse_078738533531-if01-event-kbd"; 35 + persist-keyboard0 = "usb-Microsoft_Natural®_Ergonomic_Keyboard_4000-event-kbd"; 36 + persist-keyboard1 = "usb-Microsoft_Natural®_Ergonomic_Keyboard_4000-if01-event-kbd"; 37 + } 38 + ''; 39 + }; 40 + }; 41 + 42 + config = lib.mkIf cfg.enable { 43 + 44 + systemd.services.persistent-evdev = { 45 + documentation = [ "https://github.com/aiberia/persistent-evdev/blob/master/README.md" ]; 46 + description = "Persistent evdev proxy"; 47 + wantedBy = [ "multi-user.target" ]; 48 + 49 + serviceConfig = { 50 + Restart = "on-failure"; 51 + ExecStart = "${pkgs.persistent-evdev}/bin/persistent-evdev.py ${configFile}"; 52 + CacheDirectory = "persistent-evdev"; 53 + }; 54 + }; 55 + 56 + services.udev.packages = [ pkgs.persistent-evdev ]; 57 + }; 58 + 59 + meta.maintainers = with lib.maintainers; [ lodi ]; 60 + }
+42
pkgs/servers/persistent-evdev/default.nix
···
··· 1 + { lib, buildPythonPackage, fetchFromGitHub, python3Packages }: 2 + 3 + buildPythonPackage rec { 4 + pname = "persistent-evdev"; 5 + version = "unstable-2022-05-07"; 6 + 7 + src = fetchFromGitHub { 8 + owner = "aiberia"; 9 + repo = pname; 10 + rev = "52bf246464e09ef4e6f2e1877feccc7b9feba164"; 11 + sha256 = "d0i6DL/qgDELet4ew2lyVqzd9TApivRxL3zA3dcsQXY="; 12 + }; 13 + 14 + propagatedBuildInputs = with python3Packages; [ 15 + evdev pyudev 16 + ]; 17 + 18 + postPatch = '' 19 + patchShebangs bin/persistent-evdev.py 20 + ''; 21 + 22 + dontBuild = true; 23 + 24 + installPhase = '' 25 + mkdir -p $out/bin 26 + cp bin/persistent-evdev.py $out/bin 27 + 28 + mkdir -p $out/etc/udev/rules.d 29 + cp udev/60-persistent-input-uinput.rules $out/etc/udev/rules.d 30 + ''; 31 + 32 + # has no tests 33 + doCheck = false; 34 + 35 + meta = with lib; { 36 + homepage = "https://github.com/aiberia/persistent-evdev"; 37 + description = "Persistent virtual input devices for qemu/libvirt/evdev hotplug support"; 38 + license = licenses.mit; 39 + maintainers = [ maintainers.lodi ]; 40 + platforms = platforms.linux; 41 + }; 42 + }
+2
pkgs/top-level/all-packages.nix
··· 4757 4758 evdevremapkeys = callPackage ../tools/inputmethods/evdevremapkeys { }; 4759 4760 evscript = callPackage ../tools/inputmethods/evscript { }; 4761 4762 gebaar-libinput = callPackage ../tools/inputmethods/gebaar-libinput { stdenv = gcc10StdenvCompat; };
··· 4757 4758 evdevremapkeys = callPackage ../tools/inputmethods/evdevremapkeys { }; 4759 4760 + persistent-evdev = python3Packages.callPackage ../servers/persistent-evdev { }; 4761 + 4762 evscript = callPackage ../tools/inputmethods/evscript { }; 4763 4764 gebaar-libinput = callPackage ../tools/inputmethods/gebaar-libinput { stdenv = gcc10StdenvCompat; };