diff --git a/modules/programs/k9s.nix b/modules/programs/k9s.nix index b32769cc..78dbe71c 100644 --- a/modules/programs/k9s.nix +++ b/modules/programs/k9s.nix @@ -8,7 +8,7 @@ let yamlFormat = pkgs.formats.yaml { }; in { - meta.maintainers = [ hm.maintainers.katexochen ]; + meta.maintainers = with maintainers; [ katexochen liyangau ]; options.programs.k9s = { enable = @@ -49,6 +49,29 @@ in { }; ''; }; + + hotkey = mkOption { + type = yamlFormat.type; + default = { }; + description = '' + hotkeys written to + {file}`$XDG_CONFIG_HOME/k9s/hotkey.yml`. See + + for supported values. + ''; + example = literalExpression '' + hotkey = { + # Make sure this is camel case + hotKey = { + shift-0 = { + shortCut = "Shift-0"; + description = "Viewing pods"; + command = "pods"; + }; + }; + }; + ''; + }; }; config = mkIf cfg.enable { @@ -61,5 +84,9 @@ in { xdg.configFile."k9s/skin.yml" = mkIf (cfg.skin != { }) { source = yamlFormat.generate "k9s-skin" cfg.skin; }; + + xdg.configFile."k9s/hotkey.yml" = mkIf (cfg.hotkey != { }) { + source = yamlFormat.generate "k9s-hotkey" cfg.hotkey; + }; }; } diff --git a/tests/modules/programs/k9s/example-hotkey-expected.yml b/tests/modules/programs/k9s/example-hotkey-expected.yml new file mode 100644 index 00000000..cae3005d --- /dev/null +++ b/tests/modules/programs/k9s/example-hotkey-expected.yml @@ -0,0 +1,5 @@ +hotKey: + shift-0: + command: pods + description: Viewing pods + shortCut: Shift-0 diff --git a/tests/modules/programs/k9s/example-settings.nix b/tests/modules/programs/k9s/example-settings.nix index ffe52144..0100aa93 100644 --- a/tests/modules/programs/k9s/example-settings.nix +++ b/tests/modules/programs/k9s/example-settings.nix @@ -13,7 +13,15 @@ headless = false; }; }; - + hotkey = { + hotKey = { + shift-0 = { + shortCut = "Shift-0"; + description = "Viewing pods"; + command = "pods"; + }; + }; + }; skin = { k9s = { body = { @@ -35,8 +43,12 @@ home-files/.config/k9s/config.yml \ ${./example-config-expected.yml} assertFileExists home-files/.config/k9s/skin.yml + assertFileExists home-files/.config/k9s/hotkey.yml assertFileContent \ home-files/.config/k9s/skin.yml \ ${./example-skin-expected.yml} + assertFileContent \ + home-files/.config/k9s/hotkey.yml \ + ${./example-hotkey-expected.yml} ''; }