From 28614f6861af9ed54a62780c79720c1413baed19 Mon Sep 17 00:00:00 2001 From: rgri Date: Thu, 2 Nov 2023 11:17:33 -0500 Subject: [PATCH] mouse-actions: init at 0.4.4 Co-authored-by: Donovan Glover Co-authored-by: Arne Keller <2012gdwu+github@posteo.de> --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/mouse-actions.nix | 15 +++++++ pkgs/by-name/mo/mouse-actions/package.nix | 49 +++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 nixos/modules/programs/mouse-actions.nix create mode 100644 pkgs/by-name/mo/mouse-actions/package.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 2a6ca202024b..780951468103 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -213,6 +213,7 @@ ./programs/minipro.nix ./programs/miriway.nix ./programs/mosh.nix + ./programs/mouse-actions.nix ./programs/msmtp.nix ./programs/mtr.nix ./programs/nano.nix diff --git a/nixos/modules/programs/mouse-actions.nix b/nixos/modules/programs/mouse-actions.nix new file mode 100644 index 000000000000..fdf39d56d383 --- /dev/null +++ b/nixos/modules/programs/mouse-actions.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.programs.mouse-actions; +in + { + options.programs.mouse-actions = { + enable = lib.mkEnableOption '' + mouse-actions udev rules. This is a prerequisite for using mouse-actions without being root. + ''; + }; + config = lib.mkIf cfg.enable { + services.udev.packages = [ pkgs.mouse-actions ]; + }; + } diff --git a/pkgs/by-name/mo/mouse-actions/package.nix b/pkgs/by-name/mo/mouse-actions/package.nix new file mode 100644 index 000000000000..652c5ed4243f --- /dev/null +++ b/pkgs/by-name/mo/mouse-actions/package.nix @@ -0,0 +1,49 @@ +{ lib +, fetchFromGitHub +, rustPlatform +, pkg-config +, libX11 +, libXi +, libXtst +, libevdev +}: + +rustPlatform.buildRustPackage rec { + pname = "mouse-actions"; + version = "0.4.4"; + + src = fetchFromGitHub { + owner = "jersou"; + repo = "mouse-actions"; + rev = "v${version}"; + hash = "sha256-02E4HrKIoBV3qZPVH6Tjz9Bv/mh5C8amO1Ilmd+YO5g="; + }; + + cargoHash = "sha256-5SUVZlrXIPtlu9KBzucZDCp5t5t8Z4/Nfht2Pw5agVI="; + + buildInputs = [ + libX11 + libXi + libXtst + libevdev + ]; + + nativeBuildInputs = [ + pkg-config + ]; + + postInstall = '' + mkdir -p $out/etc/udev/rules.d/ + echo 'KERNEL=="uinput", SUBSYSTEM=="misc", TAG+="uaccess", OPTIONS+="static_node=uinput"' >> $out/etc/udev/rules.d/80-mouse-actions.rules + echo 'KERNEL=="/dev/input/event*", SUBSYSTEM=="misc", TAG+="uaccess", OPTIONS+="static_node=uinput"' >> $out/etc/udev/rules.d/80-mouse-actions.rules + ''; + + meta = with lib; { + description = "Execute commands from mouse events such as clicks/wheel on the side/corners of the screen, or drawing shapes"; + homepage = "https://github.com/jersou/mouse-actions"; + license = licenses.mit; + maintainers = with maintainers; [ rgri ]; + mainProgram = "mouse-actions"; + platforms = platforms.linux; + }; +}