grafana-alloy: don't build the frontend twice
[NixPkgs.git] / nixos / modules / services / misc / persistent-evdev.nix
blob650752abd215119a08b76e0154c5c0d6699843a2
1 { config, lib, pkgs, ... }:
3 let
4   cfg = config.services.persistent-evdev;
5   settingsFormat = pkgs.formats.json {};
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   };
13   options.services.persistent-evdev = {
14     enable = lib.mkEnableOption "virtual input devices that persist even if the backing device is hotplugged";
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.
22         Physical devices should already exist in {file}`/dev/input/by-id/`.
23         Proxy devices will be automatically given a `uinput-` prefix.
25         See the [project page](https://github.com/aiberia/persistent-evdev#example-usage-with-libvirt)
26         for example configuration of virtual devices with libvirt
27         and remember to add `uinput-*` devices to the qemu
28         `cgroup_device_acl` list (see [](#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   };
42   config = lib.mkIf cfg.enable {
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" ];
49       serviceConfig = {
50         Restart = "on-failure";
51         ExecStart = "${pkgs.persistent-evdev}/bin/persistent-evdev.py ${configFile}";
52         CacheDirectory = "persistent-evdev";
53       };
54     };
56     services.udev.packages = [ pkgs.persistent-evdev ];
57   };
59   meta.maintainers = with lib.maintainers; [ lodi ];