diff --git a/nixos/modules/programs/mouse-actions.nix b/nixos/modules/programs/mouse-actions.nix index 73dc783e3100..297cc4d3bfe7 100644 --- a/nixos/modules/programs/mouse-actions.nix +++ b/nixos/modules/programs/mouse-actions.nix @@ -3,13 +3,39 @@ 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 +{ + options.programs.mouse-actions = { + enable = lib.mkEnableOption "" // { + description = '' + Whether to install and set up mouse-actions and it's udev rules. + + Note that only users in the "uinput" group will be able to use the package ''; }; - config = lib.mkIf cfg.enable { - services.udev.packages = [ pkgs.mouse-actions ]; + package = lib.mkPackageOption pkgs "mouse-actions" { + example = "mouse-actions-gui"; }; - } + autorun = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Whether to start a user service to run mouse-actions on startup. + ''; + }; + }; + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + services.udev.packages = [ cfg.package ]; + systemd.user.services.mouse-actions = lib.mkIf cfg.autorun { + description = "mouse-actions launcher"; + wantedBy = [ "graphical-session.target" ]; + bindsTo = [ "graphical-session.target" ]; + after = [ "graphical-session.target" ]; + environment.PATH = lib.mkForce null; # don't use the default PATH provided by NixOS + serviceConfig = { + ExecStart = "${lib.getExe cfg.package} start"; + PassEnvironment = "PATH"; # inherit PATH from user environment + }; + }; + }; +} diff --git a/pkgs/by-name/mo/mouse-actions-gui/80-mouse-actions.rules b/pkgs/by-name/mo/mouse-actions-gui/80-mouse-actions.rules new file mode 100644 index 000000000000..7d07d034c0fb --- /dev/null +++ b/pkgs/by-name/mo/mouse-actions-gui/80-mouse-actions.rules @@ -0,0 +1,2 @@ +KERNEL=="uinput", SUBSYSTEM=="misc", TAG+="uaccess", OPTIONS+="static_node=uinput" +KERNEL=="/dev/input/event*", SUBSYSTEM=="misc", TAG+="uaccess", OPTIONS+="static_node=uinput" diff --git a/pkgs/by-name/mo/mouse-actions-gui/package.nix b/pkgs/by-name/mo/mouse-actions-gui/package.nix new file mode 100644 index 000000000000..96051b6ab3e6 --- /dev/null +++ b/pkgs/by-name/mo/mouse-actions-gui/package.nix @@ -0,0 +1,97 @@ +{ + lib, + stdenv, + fetchFromGitHub, + + npmHooks, + fetchNpmDeps, + nodejs, + + rustPlatform, + cargo, + rustc, + cargo-tauri, + + pkg-config, + wrapGAppsHook3, + libXtst, + libevdev, + gtk3, + libsoup, + webkitgtk, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "mouse-actions-gui"; + version = "0.4.4"; + + src = fetchFromGitHub { + owner = "jersou"; + repo = "mouse-actions"; + rev = "v${finalAttrs.version}"; + hash = "sha256-02E4HrKIoBV3qZPVH6Tjz9Bv/mh5C8amO1Ilmd+YO5g="; + }; + + sourceRoot = "${finalAttrs.src.name}/config-editor"; + + nativeBuildInputs = [ + npmHooks.npmConfigHook + nodejs + rustPlatform.cargoSetupHook + cargo + rustc + cargo-tauri + pkg-config + wrapGAppsHook3 + ]; + + buildInputs = [ + # Base deps + libXtst + libevdev + + # Tauri deps + gtk3 + libsoup + webkitgtk + ]; + + npmDeps = fetchNpmDeps { + inherit (finalAttrs) src sourceRoot; + hash = "sha256-Rnr5jRupdUu6mIsWvdN6AnQnsxB5h31n/24pYslGs5g="; + }; + + cargoRoot = "src-tauri"; + + cargoDeps = rustPlatform.fetchCargoTarball { + name = "${finalAttrs.pname}-${finalAttrs.version}"; + inherit (finalAttrs) src; + sourceRoot = "${finalAttrs.sourceRoot}/${finalAttrs.cargoRoot}"; + hash = "sha256-VQFRatnxzmywAiMLfkVgB7g8AFoqfWFYjt/vezpE1o8="; + }; + + buildPhase = '' + runHook preBuild + cargo-tauri build -b deb + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + install -Dm644 ${./80-mouse-actions.rules} $out/etc/udev/rules.d/80-mouse-actions.rules + cp -r src-tauri/target/release/bundle/deb/*/data/usr/* $out + + runHook postInstall + ''; + + meta = { + changelog = "https://github.com/jersou/mouse-actions/blob/${finalAttrs.src.rev}/CHANGELOG.md"; + description = "Mouse event based command executor, a mix between Easystroke and Comiz edge commands"; + homepage = "https://github.com/jersou/mouse-actions"; + license = lib.licenses.mit; + mainProgram = "mouse-actions-gui"; + maintainers = with lib.maintainers; [ tomasajt ]; + platforms = lib.platforms.linux; + }; +})