diff options
Diffstat (limited to 'nixpkgs/nixos/modules/services/hardware/evscript.nix')
-rw-r--r-- | nixpkgs/nixos/modules/services/hardware/evscript.nix | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/hardware/evscript.nix b/nixpkgs/nixos/modules/services/hardware/evscript.nix new file mode 100644 index 000000000000..8caf9d38faaf --- /dev/null +++ b/nixpkgs/nixos/modules/services/hardware/evscript.nix @@ -0,0 +1,47 @@ +{ pkgs, lib, config, ... }: + +let + cfg = config.services.evscript; + +in +{ + options = with lib; { + services.evscript = { + enable = mkEnableOption "the evscript service"; + + package = mkOption { + description = "evscript package to use for the evscript service"; + type = types.package; + default = pkgs.evscript; + }; + + devices = mkOption { + description = "evdev devices for evscript to listen to"; + type = types.listOf types.path; + example = [ "/dev/input/by-path/pci-0000:00:1d.0-usb-0:1.1:1.0-event-kbd" ]; + }; + + script = mkOption { + description = "Dyon script for evscript service to run"; + type = types.path; + }; + }; + }; + + config = lib.mkIf cfg.enable { + services.udev.extraRules = '' + KERNEL=="uinput", MODE="0660", GROUP="input" + ''; + + systemd.services.evscript = { + wantedBy = [ "multi-user.target" ]; + serviceConfig.DynamicUser = true; + serviceConfig.SupplementaryGroups = [ "input" ]; + script = '' + ${cfg.package}/bin/evscript \ + ${lib.concatMapStringsSep " " (d: "-d ${d}") cfg.devices} \ + -f ${cfg.script} + ''; + }; + }; +} |