at master 1.3 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.programs.mouse-actions; 10in 11{ 12 options.programs.mouse-actions = { 13 enable = lib.mkEnableOption "" // { 14 description = '' 15 Whether to install and set up mouse-actions and it's udev rules. 16 17 Note that only users in the "uinput" group will be able to use the package 18 ''; 19 }; 20 package = lib.mkPackageOption pkgs "mouse-actions" { 21 example = "mouse-actions-gui"; 22 }; 23 autorun = lib.mkOption { 24 type = lib.types.bool; 25 default = false; 26 description = '' 27 Whether to start a user service to run mouse-actions on startup. 28 ''; 29 }; 30 }; 31 config = lib.mkIf cfg.enable { 32 environment.systemPackages = [ cfg.package ]; 33 services.udev.packages = [ cfg.package ]; 34 systemd.user.services.mouse-actions = lib.mkIf cfg.autorun { 35 description = "mouse-actions launcher"; 36 wantedBy = [ "graphical-session.target" ]; 37 bindsTo = [ "graphical-session.target" ]; 38 after = [ "graphical-session.target" ]; 39 environment.PATH = lib.mkForce null; # don't use the default PATH provided by NixOS 40 serviceConfig = { 41 ExecStart = "${lib.getExe cfg.package} start"; 42 PassEnvironment = "PATH"; # inherit PATH from user environment 43 }; 44 }; 45 }; 46}