From d183736d699bf65c1fbf5b3b7bbfac2f28d726cd Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Wed, 2 Dec 2020 08:46:57 +1000 Subject: [PATCH] kubectl: use installShellFiles --- .../networking/cluster/kubectl/default.nix | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pkgs/applications/networking/cluster/kubectl/default.nix b/pkgs/applications/networking/cluster/kubectl/default.nix index fed40523a9b7..c550a0e2f2b6 100644 --- a/pkgs/applications/networking/cluster/kubectl/default.nix +++ b/pkgs/applications/networking/cluster/kubectl/default.nix @@ -1,27 +1,24 @@ -{ stdenv, kubernetes }: +{ stdenv, kubernetes, installShellFiles }: stdenv.mkDerivation { name = "kubectl-${kubernetes.version}"; # kubectl is currently part of the main distribution but will eventially be # split out (see homepage) - src = kubernetes; + dontUnpack = true; + + nativeBuildInputs = [ installShellFiles ]; outputs = [ "out" "man" ]; installPhase = '' - mkdir -p \ - "$out/bin" \ - "$out/share/bash-completion/completions" \ - "$out/share/zsh/site-functions" \ - "$man/share/man/man1" + install -D ${kubernetes}/bin/kubectl -t $out/bin - cp bin/kubectl $out/bin/kubectl + installManPage "${kubernetes.man}/share/man/man1"/kubectl* - cp "${kubernetes.man}/share/man/man1"/kubectl* "$man/share/man/man1" - - $out/bin/kubectl completion bash > $out/share/bash-completion/completions/kubectl - $out/bin/kubectl completion zsh > $out/share/zsh/site-functions/_kubectl + installShellCompletion --cmd kubectl \ + --bash <($out/bin/kubectl completion bash) \ + --zsh <($out/bin/kubectl completion zsh) ''; meta = kubernetes.meta // {