Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-01-17 14:27:27 +00:00
parent 8a9355183d
commit 67e7549452
4 changed files with 299 additions and 23 deletions

View File

@@ -4,6 +4,16 @@
}:
{ pkgs, ... }:
{
nixpkgs.overlays = [
(final: prev: {
k9s = prev.k9s.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [ ./remove-splash.patch ];
});
})
];
environment.persistence."/cache"."${home}/.kube/cache" = { };
home-manager.users.${user} = {
home.packages = with pkgs; [
kubectl
@@ -11,32 +21,52 @@
kind
];
programs.zsh = {
initExtra = ''
kubeswitch() {
local target="$HOME/.kube/$1"
local config="$HOME/.kube/config"
programs = {
k9s = {
enable = true;
if [[ -f "$target" && "$target" != "$config" ]]; then
ln -sf "$target" "$config"
echo "Switched kube context to $1"
p10k reload
else
echo "Invalid kube context: $1"
echo "Ensure the file exists in ~/.kube"
fi
}
settings.k9s = {
skipLatestRevCheck = true;
liveViewAutoRefresh = true;
refreshRate = 1;
_kubeswitch_completion() {
local dir="$HOME/.kube"
local config="$dir/config"
compadd -- ''${(f)"$(find "$dir" -maxdepth 1 \( -type f -o -type l \) -not -name 'config' -exec basename {} \;)"}
}
ui = {
skin = "matugen";
logoless = true;
reactive = true;
};
};
};
compdef _kubeswitch_completion kubeswitch
'';
zsh = {
initExtra = ''
kubeswitch() {
local target="$HOME/.kube/$1"
local config="$HOME/.kube/config"
p10k.extraRightPromptElements = [ "kubecontext" ];
if [[ -f "$target" && "$target" != "$config" ]]; then
ln -sf "$target" "$config"
echo "Switched kube context to $1"
p10k reload
else
echo "Invalid kube context: $1"
echo "Ensure the file exists in ~/.kube"
fi
}
_kubeswitch_completion() {
local dir="$HOME/.kube"
local config="$dir/config"
compadd -- ''${(f)"$(find "$dir" -maxdepth 1 \( -type f -o -type l \) -not -name 'config' -exec basename {} \;)"}
}
compdef _kubeswitch_completion kubeswitch
'';
p10k.extraRightPromptElements = [ "kubecontext" ];
};
};
theme.template."${home}/.config/k9s/skins/matugen.yaml".source = ./theme.yaml;
};
}