nixos-config/modules/services/input-remapper/default.nix

41 lines
1.2 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
let
2022-02-02 14:55:38 +00:00
cfg = config.ptw.services.input-remapper;
in {
2022-02-02 14:55:38 +00:00
options.ptw.services.input-remapper = {
enable = lib.mkEnableOption "Enable the input-remapper service and install it";
postStartCommand = lib.mkOption {
default = "";
description = "Command to be executed after the input-remapper service has been started";
# type = ;
};
};
config = lib.mkIf cfg.enable {
# TODO: Assert that uinput is in kernelModules
services.udev = {
2022-02-02 14:55:38 +00:00
packages = with pkgs; [ input-remapper ];
extraRules = ''
KERNEL=="uinput", GROUP="input", MODE="0660"
'';
};
environment.systemPackages = [
2022-02-02 14:55:38 +00:00
pkgs.input-remapper # Custom package
];
2022-02-02 14:55:38 +00:00
systemd.user.services.input-remapper = {
description = "A tool to change the mapping of your input device buttons";
wantedBy = [ "default.target" ];
serviceConfig = {
Type = "simple";
2022-02-02 14:55:38 +00:00
ExecStart = "${pkgs.input-remapper}/bin/input-remapper-service";
Restart = "always";
# NOTE: The Tartarus may not be connected, so don't fail if we cannot set the preset
2022-02-02 14:55:38 +00:00
ExecStartPost = cfg.postStartCommand;
};
};
};
}