mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-10 16:45:51 +03:00
nixos/keyd: add support for multi-file configuration
Add `keyboards` option to define different configurations for different IDs. This creates the appropriate files in `/etc/keyd` instead of just `default.conf` as before. Add `23.11` release note entry. Add `mkRemovedOptionModule` for the old API with a note on how to revert the old behavior.
This commit is contained in:
parent
4a729ce4b1
commit
2d3bf20086
@ -60,6 +60,8 @@
|
|||||||
|
|
||||||
- `util-linux` is now supported on Darwin and is no longer an alias to `unixtools`. Use the `unixtools.util-linux` package for access to the Apple variants of the utilities.
|
- `util-linux` is now supported on Darwin and is no longer an alias to `unixtools`. Use the `unixtools.util-linux` package for access to the Apple variants of the utilities.
|
||||||
|
|
||||||
|
- `services.keyd` changed API. Now you can create multiple configuration files.
|
||||||
|
|
||||||
- `services.ddclient` has been removed on the request of the upstream maintainer because it is unmaintained and has bugs. Please switch to a different software like `inadyn` or `knsupdate`.
|
- `services.ddclient` has been removed on the request of the upstream maintainer because it is unmaintained and has bugs. Please switch to a different software like `inadyn` or `knsupdate`.
|
||||||
|
|
||||||
- The `vlock` program from the `kbd` package has been moved into its own package output and should now be referenced explicitly as `kbd.vlock` or replaced with an alternative such as the standalone `vlock` package or `physlock`.
|
- The `vlock` program from the `kbd` package has been moved into its own package output and should now be referenced explicitly as `kbd.vlock` or replaced with an alternative such as the standalone `vlock` package or `physlock`.
|
||||||
|
@ -3,12 +3,9 @@ with lib;
|
|||||||
let
|
let
|
||||||
cfg = config.services.keyd;
|
cfg = config.services.keyd;
|
||||||
settingsFormat = pkgs.formats.ini { };
|
settingsFormat = pkgs.formats.ini { };
|
||||||
in
|
|
||||||
{
|
|
||||||
options = {
|
|
||||||
services.keyd = {
|
|
||||||
enable = mkEnableOption (lib.mdDoc "keyd, a key remapping daemon");
|
|
||||||
|
|
||||||
|
keyboardOptions = { ... }: {
|
||||||
|
options = {
|
||||||
ids = mkOption {
|
ids = mkOption {
|
||||||
type = types.listOf types.string;
|
type = types.listOf types.string;
|
||||||
default = [ "*" ];
|
default = [ "*" ];
|
||||||
@ -35,24 +32,71 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
description = lib.mdDoc ''
|
description = lib.mdDoc ''
|
||||||
Configuration, except `ids` section, that is written to {file}`/etc/keyd/default.conf`.
|
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>).
|
||||||
See <https://github.com/rvaiya/keyd> how to configure.
|
See <https://github.com/rvaiya/keyd> how to configure.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
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`).
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
environment.etc."keyd/default.conf".source = pkgs.runCommand "default.conf"
|
# Creates separate files in the `/etc/keyd/` directory for each key in the dictionary
|
||||||
{
|
environment.etc = mapAttrs'
|
||||||
ids = ''
|
(name: options:
|
||||||
[ids]
|
nameValuePair "keyd/${name}.conf" {
|
||||||
${concatStringsSep "\n" cfg.ids}
|
source = pkgs.runCommand "${name}.conf"
|
||||||
'';
|
{
|
||||||
passAsFile = [ "ids" ];
|
ids = ''
|
||||||
} ''
|
[ids]
|
||||||
cat $idsPath <(echo) ${settingsFormat.generate "keyd-main.conf" cfg.settings} >$out
|
${concatStringsSep "\n" options.ids}
|
||||||
'';
|
'';
|
||||||
|
passAsFile = [ "ids" ];
|
||||||
|
} ''
|
||||||
|
cat $idsPath <(echo) ${settingsFormat.generate "keyd-${name}.conf" options.settings} >$out
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
cfg.keyboards;
|
||||||
|
|
||||||
hardware.uinput.enable = lib.mkDefault true;
|
hardware.uinput.enable = lib.mkDefault true;
|
||||||
|
|
||||||
@ -62,9 +106,11 @@ in
|
|||||||
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
restartTriggers = [
|
restartTriggers = mapAttrsToList
|
||||||
config.environment.etc."keyd/default.conf".source
|
(name: options:
|
||||||
];
|
config.environment.etc."keyd/${name}.conf".source
|
||||||
|
)
|
||||||
|
cfg.keyboards;
|
||||||
|
|
||||||
# this is configurable in 2.4.2, later versions seem to remove this option.
|
# this is configurable in 2.4.2, later versions seem to remove this option.
|
||||||
# post-2.4.2 may need to set makeFlags in the derivation:
|
# post-2.4.2 may need to set makeFlags in the derivation:
|
||||||
|
@ -32,7 +32,7 @@ let
|
|||||||
nodes.machine = {
|
nodes.machine = {
|
||||||
services.keyd = {
|
services.keyd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
inherit settings;
|
keyboards.default = { inherit settings; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user