{ config, pkgs, lib, ... }:

let
  cfg = config.samfelag.modules.system.kanata;
in
{
  options.samfelag.modules.system.kanata = {
    enable = lib.mkEnableOption "kanata";
  };

  config = lib.mkIf cfg.enable {
    users.users.${config.user.name}.extraGroups = [
      "input"
      "uinput"
    ];
    services.kanata = {
      enable = true;
      keyboards = {
        internalKeyboard = {
          extraDefCfg = "process-unmapped-keys yes";
          configFile = ../../config/kanata/kanata.kbd;
        };
      };
    };
  };
}
