Change:
}; }; description = lib.mdDoc '' <del> Configuration, except `ids` section, that is written to {file}`/etc/keyd/default.conf`. </del> <ins> Configuration, except `ids` section, that is written to {file}`/etc/keyd/<keyboard>.conf`. Appropriate names can be used to write non-alpha keys, for example "equal" instead of "=" sign (see <https://github.com/NixOS/nixpkgs/issues/236622>). </ins> See <https://github.com/rvaiya/keyd> how to configure. ''; }; }; }; <ins> in { imports = [ (mkRemovedOptionModule [ "services" "keyd" "ids" ] ''Use keyboards.<filename>.ids instead. If you don't need a multi-file configuration, just add keyboards.default before the ids. See https://github.com/NixOS/nixpkgs/pull/243271.'') (mkRemovedOptionModule [ "services" "keyd" "settings" ] ''Use keyboards.<filename>.settings instead. If you don't need a multi-file configuration, just add keyboards.default before the settings. See https://github.com/NixOS/nixpkgs/pull/243271.'') ]; options.services.keyd = { enable = mkEnableOption (lib.mdDoc "keyd, a key remapping daemon"); keyboards = mkOption { type = types.attrsOf (types.submodule keyboardOptions); default = { }; example = literalExpression '' { default = { ids = [ "*" ]; settings = { main = { capslock = "overload(control, esc)"; }; }; }; externalKeyboard = { ids = [ "1ea7:0907" ]; settings = { main = { esc = capslock; }; }; }; } ''; description = mdDoc '' Configuration for one or more device IDs. Corresponding files in the /etc/keyd/ directory are created according to the name of the keys (like `default` or `externalKeyboard`). ''; }; }; </ins> config = mkIf cfg.enable { <del> environment.etc."keyd/default.conf".source = pkgs.runCommand "default.conf" { ids = '' [ids] ${concatStringsSep "n" cfg.ids} ''; passAsFile = [ "ids" ]; } '' cat $idsPath <(echo) ${settingsFormat.generate "keyd-main.conf" cfg.settings} >$out ''; </del> <ins> # Creates separate files in the `/etc/keyd/` directory for each key in the dictionary environment.etc = mapAttrs' (name: options: nameValuePair "keyd/${name}.conf" { source = pkgs.runCommand "${name}.conf" { ids = '' [ids] ${concatStringsSep "n" options.ids} ''; passAsFile = [ "ids" ]; } '' cat $idsPath <(echo) ${settingsFormat.generate "keyd-${name}.conf" options.settings} >$out ''; }) cfg.keyboards; </ins> hardware.uinput.enable = lib.mkDefault true;

Discussion:
Currently options of keyd service () allow for creating single configuration file (). I need to apply different configs to different keyboards (which is possible by creating multiple conf files in ). Could NixOS keyd module expose suitable option(s) for this?
I'll look into it. Can you provide an example of what these files should look like? Is it the same as "" but with a different "id" section?
Thanks very much! Exactly. The format of all conf files is the same. Each file specifies different to match different keyboards.
Ok, I will think how I can do it nicely soon
this patch is ready. If you are using unstable nixos, you can update the packages with with a flake switch (do you use flakes?). Can you confirm that the multi-file configuration is working now?
Hello, I am using keyd and NixOS unstable. I updated my to account for the changes related to this issue. I then ran and my built-in laptop keyboard, which I use keyd with, stopped responding to input. I plugged in an external keyboard, which worked fine, and had a look at the systemd logs for keyd.service and the new configuration files. I did not see anything unusual. I then ran and my keyboard started working again. I can consistently reproduce this by rebooting and re-running the above command. If anyone else has this issue and doesn't have an external keyboard handy, I suggest trying the following steps, as these also allowed me to update without disabling my keyboard: out the portion of your NixOS config. NixOS update command e.g. portion and run again As for the new configuration: I have not tested the multi-file configuration properly as I only use it for my laptop keyboard but the new file layout looks correct .
Hi unfortunately I also have this problem from time to time when the home manager restarts many services at once. I have an easier workaround - just press . The keyd docs say this command will stop keyd, but for me it restarts it and everything works like a charm. Also try using or instead of and you should probably run into this situation less often. I think because when you create a lock file from scratch, all services will be restarted, but with the only some of them. I'm not sure though, just a guess.