Skip to content

Commit

Permalink
k9s: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
katexochen authored and rycee committed Oct 24, 2022
1 parent 186d939 commit 7dc4e4e
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ Makefile @thiagokokada

/modules/programs/just.nix @maximsmol

/modules/programs/k9s.nix @katexochen
/tests/modules/programs/k9s @katexochen

/modules/programs/keychain.nix @marsam

/modules/programs/kodi.nix @dwagenk
Expand Down
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
fingerprint = "2BE3 BAFD 793E A349 ED1F F00F 04D0 CEAF 916A 9A40";
}];
};
katexochen = {
name = "Paul Meyer";
email = "[email protected]";
github = "katexochen";
githubId = 49727155;
};
kubukoz = {
name = "Jakub Kozłowski";
email = "[email protected]";
Expand Down
7 changes: 7 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,13 @@ in
enabling this.
'';
}

{
time = "2022-10-24T22:05:27+00:00";
message = ''
A new module is available: 'programs.k9s'.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ let
./programs/java.nix
./programs/jq.nix
./programs/just.nix
./programs/k9s.nix
./programs/kakoune.nix
./programs/keychain.nix
./programs/kitty.nix
Expand Down
65 changes: 65 additions & 0 deletions modules/programs/k9s.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{ config, lib, pkgs, ... }:

with lib;

let

cfg = config.programs.k9s;
yamlFormat = pkgs.formats.yaml { };

in {
meta.maintainers = [ hm.maintainers.katexochen ];

options.programs.k9s = {
enable =
mkEnableOption "k9s - Kubernetes CLI To Manage Your Clusters In Style";

package = mkPackageOption pkgs "k9s" { };

settings = mkOption {
type = yamlFormat.type;
default = { };
description = ''
Configuration written to
<filename>$XDG_CONFIG_HOME/k9s/config.yml</filename>. See
<link xlink:href="https://k9scli.io/topics/config/"/>
for supported values.
'';
example = literalExpression ''
k9s = {
refreshRate = 2;
};
'';
};

skin = mkOption {
type = yamlFormat.type;
default = { };
description = ''
Skin written to
<filename>$XDG_CONFIG_HOME/k9s/skin.yml</filename>. See
<link xlink:href="https://k9scli.io/topics/skins/"/>
for supported values.
'';
example = literalExpression ''
k9s = {
body = {
fgColor = "dodgerblue";
};
};
'';
};
};

config = mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile."k9s/config.yml" = mkIf (cfg.settings != { }) {
source = yamlFormat.generate "k9s-config" cfg.settings;
};

xdg.configFile."k9s/skin.yml" = mkIf (cfg.skin != { }) {
source = yamlFormat.generate "k9s-skin" cfg.skin;
};
};
}
1 change: 1 addition & 0 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import nmt {
./modules/programs/hyfetch
./modules/programs/i3status
./modules/programs/irssi
./modules/programs/k9s
./modules/programs/kakoune
./modules/programs/kitty
./modules/programs/less
Expand Down
4 changes: 4 additions & 0 deletions tests/modules/programs/k9s/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
k9s-example-settings = ./example-settings.nix;
k9s-empty-settings = ./empty-settings.nix;
}
11 changes: 11 additions & 0 deletions tests/modules/programs/k9s/empty-settings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{ ... }:

{
programs.k9s.enable = true;

test.stubs.k9s = { };

nmt.script = ''
assertPathNotExists home-files/.config/k9s
'';
}
5 changes: 5 additions & 0 deletions tests/modules/programs/k9s/example-config-expected.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
k9s:
enableMouse: true
headless: false
maxConnRetry: 5
refreshRate: 2
42 changes: 42 additions & 0 deletions tests/modules/programs/k9s/example-settings.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ config, ... }:

{
programs.k9s = {
enable = true;
package = config.lib.test.mkStubPackage { };

settings = {
k9s = {
refreshRate = 2;
maxConnRetry = 5;
enableMouse = true;
headless = false;
};
};

skin = {
k9s = {
body = {
fgColor = "dodgerblue";
bgColor = "#ffffff";
logoColor = "#0000ff";
};
info = {
fgColor = "lightskyblue";
sectionColor = "steelblue";
};
};
};
};

nmt.script = ''
assertFileExists home-files/.config/k9s/config.yml
assertFileContent \
home-files/.config/k9s/config.yml \
${./example-config-expected.yml}
assertFileExists home-files/.config/k9s/skin.yml
assertFileContent \
home-files/.config/k9s/skin.yml \
${./example-skin-expected.yml}
'';
}
8 changes: 8 additions & 0 deletions tests/modules/programs/k9s/example-skin-expected.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
k9s:
body:
bgColor: '#ffffff'
fgColor: dodgerblue
logoColor: '#0000ff'
info:
fgColor: lightskyblue
sectionColor: steelblue

0 comments on commit 7dc4e4e

Please sign in to comment.