fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Li Yangk9s: add hotkey option (#4617)fc2a8842

master
2.1 KiB92 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.k9s;
8  yamlFormat = pkgs.formats.yaml { };
9
10in {
11  meta.maintainers = with maintainers; [ katexochen liyangau ];
12
13  options.programs.k9s = {
14    enable =
15      mkEnableOption "k9s - Kubernetes CLI To Manage Your Clusters In Style";
16
17    package = mkPackageOption pkgs "k9s" { };
18
19    settings = mkOption {
20      type = yamlFormat.type;
21      default = { };
22      description = ''
23        Configuration written to
24        {file}`$XDG_CONFIG_HOME/k9s/config.yml`. See
25        <https://k9scli.io/topics/config/>
26        for supported values.
27      '';
28      example = literalExpression ''
29        k9s = {
30          refreshRate = 2;
31        };
32      '';
33    };
34
35    skin = mkOption {
36      type = yamlFormat.type;
37      default = { };
38      description = ''
39        Skin written to
40        {file}`$XDG_CONFIG_HOME/k9s/skin.yml`. See
41        <https://k9scli.io/topics/skins/>
42        for supported values.
43      '';
44      example = literalExpression ''
45        k9s = {
46          body = {
47            fgColor = "dodgerblue";
48          };
49        };
50      '';
51    };
52
53    hotkey = mkOption {
54      type = yamlFormat.type;
55      default = { };
56      description = ''
57        hotkeys written to
58        {file}`$XDG_CONFIG_HOME/k9s/hotkey.yml`. See
59        <https://k9scli.io/topics/hotkeys/>
60        for supported values.
61      '';
62      example = literalExpression ''
63        hotkey = {
64          # Make sure this is camel case
65          hotKey = {
66            shift-0 = {
67              shortCut = "Shift-0";
68              description = "Viewing pods";
69              command = "pods";
70            };
71          };
72        };
73      '';
74    };
75  };
76
77  config = mkIf cfg.enable {
78    home.packages = [ cfg.package ];
79
80    xdg.configFile."k9s/config.yml" = mkIf (cfg.settings != { }) {
81      source = yamlFormat.generate "k9s-config" cfg.settings;
82    };
83
84    xdg.configFile."k9s/skin.yml" = mkIf (cfg.skin != { }) {
85      source = yamlFormat.generate "k9s-skin" cfg.skin;
86    };
87
88    xdg.configFile."k9s/hotkey.yml" = mkIf (cfg.hotkey != { }) {
89      source = yamlFormat.generate "k9s-hotkey" cfg.hotkey;
90    };
91  };
92}