mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-26 01:51:37 +00:00
kubecolor: create oc alias conditionally
This commit is contained in:
parent
f9f766c600
commit
f55c5f6569
4 changed files with 63 additions and 1 deletions
|
@ -92,7 +92,10 @@ in {
|
||||||
|
|
||||||
home.shellAliases = lib.mkIf (cfg.enableAlias && (cfg.package != null)) {
|
home.shellAliases = lib.mkIf (cfg.enableAlias && (cfg.package != null)) {
|
||||||
kubectl = lib.getExe cfg.package;
|
kubectl = lib.getExe cfg.package;
|
||||||
oc = lib.mkIf (builtins.elem pkgs.openshift config.home.packages) "env KUBECTL_COMMAND=${lib.getExe pkgs.openshift} ${lib.getExe cfg.package}";
|
oc = lib.mkIf (builtins.elem pkgs.openshift config.home.packages)
|
||||||
|
"env KUBECTL_COMMAND=${lib.getExe pkgs.openshift} ${
|
||||||
|
lib.getExe cfg.package
|
||||||
|
}";
|
||||||
};
|
};
|
||||||
|
|
||||||
programs.zsh.initContent =
|
programs.zsh.initContent =
|
||||||
|
|
|
@ -2,4 +2,6 @@
|
||||||
kubecolor-empty-config = ./empty-config.nix;
|
kubecolor-empty-config = ./empty-config.nix;
|
||||||
kubecolor-example-config-default-paths = ./example-config-default-paths.nix;
|
kubecolor-example-config-default-paths = ./example-config-default-paths.nix;
|
||||||
kubecolor-example-config-xdg-paths = ./example-config-xdg-paths.nix;
|
kubecolor-example-config-xdg-paths = ./example-config-xdg-paths.nix;
|
||||||
|
kubecolor-does-have-openshift = ./does-have-openshift.nix;
|
||||||
|
kubecolor-does-not-have-openshift = ./does-not-have-openshift.nix;
|
||||||
}
|
}
|
||||||
|
|
33
tests/modules/programs/kubecolor/does-have-openshift.nix
Normal file
33
tests/modules/programs/kubecolor/does-have-openshift.nix
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.kubecolor = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage {
|
||||||
|
name = "kubecolor";
|
||||||
|
version = "0.4.0";
|
||||||
|
};
|
||||||
|
enableAlias = true;
|
||||||
|
};
|
||||||
|
programs.zsh = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage {
|
||||||
|
name = "zsh";
|
||||||
|
version = "5.9";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(self: super: rec {
|
||||||
|
openshift = config.lib.test.mkStubPackage {
|
||||||
|
name = "openshift";
|
||||||
|
version = "4.16.0";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
home.packages = [ pkgs.openshift ];
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileRegex 'home-files/.zshrc' '^alias.* oc=.*'
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
24
tests/modules/programs/kubecolor/does-not-have-openshift.nix
Normal file
24
tests/modules/programs/kubecolor/does-not-have-openshift.nix
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
programs.kubecolor = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage {
|
||||||
|
name = "kubecolor";
|
||||||
|
version = "0.4.0";
|
||||||
|
};
|
||||||
|
enableAlias = true;
|
||||||
|
};
|
||||||
|
programs.zsh = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage {
|
||||||
|
name = "zsh";
|
||||||
|
version = "5.9";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileNotRegex 'home-files/.zshrc' '^alias.* oc=.*'
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue