Loading nixos/modules/services/hardware/keyd.nix +21 −11 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ with lib; let cfg = config.services.keyd; settingsFormat = pkgs.formats.ini { }; keyboardOptions = { ... }: { options = { Loading @@ -16,7 +15,7 @@ let }; settings = mkOption { type = settingsFormat.type; type = (pkgs.formats.ini { }).type; default = { }; example = { main = { Loading @@ -37,6 +36,20 @@ let See <https://github.com/rvaiya/keyd> how to configure. ''; }; extraConfig = mkOption { type = types.lines; default = ""; example = '' [control+shift] h = left ''; description = lib.mdDoc '' Extra configuration that is appended to the end of the file. **Do not** write `ids` section here, use a separate option for it. You can use this option to define compound layers that must always be defined after the layer they are comprised. ''; }; }; }; in Loading Loading @@ -85,15 +98,12 @@ in environment.etc = mapAttrs' (name: options: nameValuePair "keyd/${name}.conf" { source = pkgs.runCommand "${name}.conf" { ids = '' text = '' [ids] ${concatStringsSep "\n" options.ids} ''; passAsFile = [ "ids" ]; } '' cat $idsPath <(echo) ${settingsFormat.generate "keyd-${name}.conf" options.settings} >$out ${generators.toINI {} options.settings} ${options.extraConfig} ''; }) cfg.keyboards; Loading nixos/tests/keyd.nix +15 −8 Original line number Diff line number Diff line Loading @@ -26,13 +26,13 @@ let ''; mkKeyboardTest = name: { settings, test }: with pkgs.lib; makeTest { mkKeyboardTest = name: { default, test }: with pkgs.lib; makeTest { inherit name; nodes.machine = { services.keyd = { enable = true; keyboards.default = { inherit settings; }; keyboards = { inherit default; }; }; }; Loading Loading @@ -70,13 +70,20 @@ let in pkgs.lib.mapAttrs mkKeyboardTest { swap-ab_and_ctrl-as-shift = { test.press = [ "a" "ctrl-b" "c" ]; test.expect = [ "b" "A" "c" ]; test.press = [ "a" "ctrl-b" "c" "alt_r-h" ]; test.expect = [ "b" "A" "c" "q" ]; default = { settings.main = { "a" = "b"; "b" = "a"; "control" = "oneshot(shift)"; "rightalt" = "layer(rightalt)"; }; extraConfig = '' [rightalt:G] h = q ''; }; }; } Loading
nixos/modules/services/hardware/keyd.nix +21 −11 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ with lib; let cfg = config.services.keyd; settingsFormat = pkgs.formats.ini { }; keyboardOptions = { ... }: { options = { Loading @@ -16,7 +15,7 @@ let }; settings = mkOption { type = settingsFormat.type; type = (pkgs.formats.ini { }).type; default = { }; example = { main = { Loading @@ -37,6 +36,20 @@ let See <https://github.com/rvaiya/keyd> how to configure. ''; }; extraConfig = mkOption { type = types.lines; default = ""; example = '' [control+shift] h = left ''; description = lib.mdDoc '' Extra configuration that is appended to the end of the file. **Do not** write `ids` section here, use a separate option for it. You can use this option to define compound layers that must always be defined after the layer they are comprised. ''; }; }; }; in Loading Loading @@ -85,15 +98,12 @@ in environment.etc = mapAttrs' (name: options: nameValuePair "keyd/${name}.conf" { source = pkgs.runCommand "${name}.conf" { ids = '' text = '' [ids] ${concatStringsSep "\n" options.ids} ''; passAsFile = [ "ids" ]; } '' cat $idsPath <(echo) ${settingsFormat.generate "keyd-${name}.conf" options.settings} >$out ${generators.toINI {} options.settings} ${options.extraConfig} ''; }) cfg.keyboards; Loading
nixos/tests/keyd.nix +15 −8 Original line number Diff line number Diff line Loading @@ -26,13 +26,13 @@ let ''; mkKeyboardTest = name: { settings, test }: with pkgs.lib; makeTest { mkKeyboardTest = name: { default, test }: with pkgs.lib; makeTest { inherit name; nodes.machine = { services.keyd = { enable = true; keyboards.default = { inherit settings; }; keyboards = { inherit default; }; }; }; Loading Loading @@ -70,13 +70,20 @@ let in pkgs.lib.mapAttrs mkKeyboardTest { swap-ab_and_ctrl-as-shift = { test.press = [ "a" "ctrl-b" "c" ]; test.expect = [ "b" "A" "c" ]; test.press = [ "a" "ctrl-b" "c" "alt_r-h" ]; test.expect = [ "b" "A" "c" "q" ]; default = { settings.main = { "a" = "b"; "b" = "a"; "control" = "oneshot(shift)"; "rightalt" = "layer(rightalt)"; }; extraConfig = '' [rightalt:G] h = q ''; }; }; }