nixpkgs/nixos/modules/programs/kubeswitch.nix
stuebinm 6afb255d97 nixos: remove all uses of lib.mdDoc
these changes were generated with nixq 0.0.2, by running

  nixq ">> lib.mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> mdDoc[remove] Argument[keep]" --batchmode nixos/**.nix
  nixq ">> Inherit >> mdDoc[remove]" --batchmode nixos/**.nix

two mentions of the mdDoc function remain in nixos/, both of which
are inside of comments.

Since lib.mdDoc is already defined as just id, this commit is a no-op as
far as Nix (and the built manual) is concerned.
2024-04-13 10:07:35 -07:00

56 lines
1.6 KiB
Nix

{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs.kubeswitch;
in
{
options = {
programs.kubeswitch = {
enable = lib.mkEnableOption "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
'';
};
}