I converted the example evdevremapkeys config file from YAML → JSON → Nix and this is the result:
Config (Nix)
settings = {
devices = [
{
input_name = "Kingsis Peripherals Evoluent VerticalMouse 4";
output_name = "remap-mouse";
remappings = {
BTN_EXTRA = [
"KEY_LEFTMETA"
"KEY_Z"
];
BTN_FORWARD = [
"KEY_LEFTMETA"
"KEY_W"
];
BTN_MIDDLE = [ "BTN_RIGHT" ];
BTN_RIGHT = [
"KEY_LEFTMETA"
"KEY_A"
];
BTN_SIDE = [ "BTN_MIDDLE" ];
};
}
{
input_name = "KINESIS FREESTYLE KB800 KB800 Kine
sis Freestyle";
input_phys = "usb-0000:00:14.0-3.3/input0";
output_name = "remap-kbd";
remappings = {
KEY_CAPSLOCK = [ "KEY_LEFTCTRL" ];
KEY_LEFTCTRL = [ "KEY_CAPSLOCK" ];
};
}
];
};
Here is also the advanced config in Nix, as a plus:
Advanced config (Nix)
settings = {
devices = [
{
input_fn = "/dev/input/event7";
input_name = "Compx 2.4G Receiver";
output_name = "remap-mouse";
remappings = {
BTN_EXTRA = [
{
code = "REL_WHEEL";
rate = 0.3;
repeat = true;
type = "EV_REL";
value = 1;
}
];
BTN_RIGHT = [
{
code = "BTN_LEFT";
count = 2;
repeat = true;
value = [
1
0
];
}
];
BTN_SIDE = [
{
code = "REL_WHEEL";
repeat = true;
type = "EV_REL";
value = -1;
}
];
REL_WHEEL = [
{
code = "BTN_RIGHT";
count = 4;
delay = true;
}
];
};
}
{
input_fn = "/dev/input/event4";
input_name = "AT Translated Set 2 keyboard";
output_name = "remap-kbd";
remappings = {
KEY_LEFTALT = [
{
code = "KEY_A";
repeat = true;
value = [
1
0
1
0
];
}
];
KEY_LEFTSHIFT = [
{
code = "KEY_A";
count = 6;
repeat = true;
value = [
1
0
];
}
];
KEY_RIGHTSHIFT = [
{
code = "KEY_A";
count = 3;
repeat = true;
value = [
1
0
1
0
];
}
];
};
}
];
};
From this, we can see that keys should be written in lists for it to work correctly:
remappings = {
- KEY_LEFTALT = "KEY_A";
+ KEY_LEFTALT = [ "KEY_A" ];
};
Alternatively, you can convert the config from YAML to JSON and import the file with:
services = {
evdevremapkeys = {
enable = true;
settings = lib.importJSON ./path/to/config.json;
};
};
We have to convert to JSON because currently there isn’t any function that imports YAML, unless you do something like this: