nixos-config/modules/services/key-mapper/default.nix

36 lines
1.1 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.ptw.services.key-mapper;
in {
options.ptw.services.key-mapper = {
enable = lib.mkEnableOption "Enable the key-mapper service and install it";
};
config = lib.mkIf cfg.enable {
# TODO: Assert that uinput is in kernelModules
services.udev = {
packages = with pkgs; [ key-mapper ];
extraRules = ''
KERNEL=="uinput", GROUP="input", MODE="0660"
'';
};
environment.systemPackages = [
pkgs.key-mapper # Custom package
];
systemd.user.services.key-mapper = {
description = "A tool to change the mapping of your input device buttons";
wantedBy = [ "default.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.key-mapper}/bin/key-mapper-service";
Restart = "always";
# NOTE: The Tartarus may not be connected, so don't fail if we cannot set the preset
ExecPostStart = "${pkgs.key-mapper}/bin/key-mapper --command start --preset NOOP --device \"Razer Razer Tartarus V2\"; exit 0";
};
};
};
}