8 cfg = config.programs.kubeswitch;
12 programs.kubeswitch = {
13 enable = lib.mkEnableOption "kubeswitch";
15 commandName = lib.mkOption {
18 description = "The name of the command to use";
21 package = lib.mkOption {
22 type = lib.types.package;
23 default = pkgs.kubeswitch;
24 defaultText = lib.literalExpression "pkgs.kubeswitch";
25 description = "The package to install for kubeswitch";
32 shell_files = pkgs.runCommand "kubeswitch-shell-files" {} ''
34 for shell in bash zsh; do
35 ${cfg.package}/bin/switcher init $shell | sed 's/switch(/${cfg.commandName}(/' > $out/share/${cfg.commandName}_init.$shell
36 ${cfg.package}/bin/switcher --cmd ${cfg.commandName} completion $shell > $out/share/${cfg.commandName}_completion.$shell
41 environment.systemPackages = [ cfg.package ];
43 programs.bash.interactiveShellInit = ''
44 source ${shell_files}/share/${cfg.commandName}_init.bash
45 source ${shell_files}/share/${cfg.commandName}_completion.bash
47 programs.zsh.interactiveShellInit = ''
48 source ${shell_files}/share/${cfg.commandName}_init.zsh
49 source ${shell_files}/share/${cfg.commandName}_completion.zsh