fly: use completion generator

There's no need to ship the pre-generated completions in the nixpkgs
tree anymore.
This commit is contained in:
Florian Klink 2020-05-15 13:47:00 +02:00
parent e4d710b1c9
commit 5d362c2335
2 changed files with 5 additions and 17 deletions

View File

@ -1,4 +1,4 @@
{ buildGoModule, fetchFromGitHub, lib, writeText }:
{ buildGoModule, fetchFromGitHub, stdenv, lib, writeText }:
buildGoModule rec {
pname = "fly";
@ -20,12 +20,10 @@ buildGoModule rec {
-X github.com/concourse/concourse.Version=${version}
'';
# The fly.bash file included with this derivation can be replaced by a
# call to `fly completion bash` once the `completion` subcommand has
# made it into a release. Similarly, `fly completion zsh` will provide
# zsh completions. https://github.com/concourse/concourse/pull/4012
postInstall = ''
install -D -m 444 ${./fly.bash} $out/share/bash-completion/completions/fly
postInstall = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
mkdir -p $out/share/{bash-completion/completions,zsh/site-functions}
$out/bin/fly completion --shell bash > $out/share/bash-completion/completions/fly
$out/bin/fly completion --shell zsh > $out/share/zsh/site-functions/_fly
'';
meta = with lib; {

View File

@ -1,10 +0,0 @@
# credits:
# https://godoc.org/github.com/jessevdk/go-flags#hdr-Completion
# https://github.com/concourse/concourse/issues/1309#issuecomment-452893900
_fly_compl() {
args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
local IFS=$'\n'
COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
return 0
}
complete -F _fly_compl fly