mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/kubeswitch: init
Add a module to activate the kubeswitch in the shell
This commit is contained in:
parent
e44c60ebad
commit
262222169f
2 changed files with 57 additions and 0 deletions
|
@ -214,6 +214,7 @@
|
||||||
./programs/kclock.nix
|
./programs/kclock.nix
|
||||||
./programs/kdeconnect.nix
|
./programs/kdeconnect.nix
|
||||||
./programs/lazygit.nix
|
./programs/lazygit.nix
|
||||||
|
./programs/kubeswitch.nix
|
||||||
./programs/less.nix
|
./programs/less.nix
|
||||||
./programs/liboping.nix
|
./programs/liboping.nix
|
||||||
./programs/light.nix
|
./programs/light.nix
|
||||||
|
|
56
nixos/modules/programs/kubeswitch.nix
Normal file
56
nixos/modules/programs/kubeswitch.nix
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
cfg = config.programs.kubeswitch;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
programs.kubeswitch = {
|
||||||
|
enable = lib.mkEnableOption (lib.mdDoc "kubeswitch");
|
||||||
|
|
||||||
|
commandName = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "kswitch";
|
||||||
|
description = "The name of the command to use";
|
||||||
|
};
|
||||||
|
|
||||||
|
package = lib.mkOption {
|
||||||
|
type = lib.types.package;
|
||||||
|
default = pkgs.kubeswitch;
|
||||||
|
defaultText = lib.literalExpression "pkgs.kubeswitch";
|
||||||
|
description = "The package to install for kubeswitch";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
shell_files = pkgs.stdenv.mkDerivation rec {
|
||||||
|
name = "kubeswitch-shell-files";
|
||||||
|
phases = [ "installPhase" ];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/share
|
||||||
|
for shell in bash zsh; do
|
||||||
|
${cfg.package}/bin/switcher init $shell | sed 's/switch(/${cfg.commandName}(/' > $out/share/${cfg.commandName}_init.$shell
|
||||||
|
${cfg.package}/bin/switcher --cmd ${cfg.commandName} completion $shell > $out/share/${cfg.commandName}_completion.$shell
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
lib.mkIf cfg.enable {
|
||||||
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
|
||||||
|
programs.bash.interactiveShellInit = ''
|
||||||
|
source ${shell_files}/share/${cfg.commandName}_init.bash
|
||||||
|
source ${shell_files}/share/${cfg.commandName}_completion.bash
|
||||||
|
'';
|
||||||
|
programs.zsh.interactiveShellInit = ''
|
||||||
|
source ${shell_files}/share/${cfg.commandName}_init.zsh
|
||||||
|
source ${shell_files}/share/${cfg.commandName}_completion.zsh
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue