terraform: add completion
Signed-off-by: lucasew <lucas59356@gmail.com>
This commit is contained in:
parent
0dffd5039b
commit
701f8d5f6d
1 changed files with 34 additions and 20 deletions
|
@ -9,6 +9,7 @@
|
||||||
, writeText
|
, writeText
|
||||||
, terraform-providers
|
, terraform-providers
|
||||||
, fetchpatch
|
, fetchpatch
|
||||||
|
, installShellFiles
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -28,12 +29,38 @@ let
|
||||||
|
|
||||||
ldflags = [ "-s" "-w" ];
|
ldflags = [ "-s" "-w" ];
|
||||||
|
|
||||||
|
subPackages = [ "." ];
|
||||||
|
|
||||||
postConfigure = ''
|
postConfigure = ''
|
||||||
# speakeasy hardcodes /bin/stty https://github.com/bgentry/speakeasy/issues/22
|
# speakeasy hardcodes /bin/stty https://github.com/bgentry/speakeasy/issues/22
|
||||||
substituteInPlace vendor/github.com/bgentry/speakeasy/speakeasy_unix.go \
|
substituteInPlace vendor/github.com/bgentry/speakeasy/speakeasy_unix.go \
|
||||||
--replace "/bin/stty" "${coreutils}/bin/stty"
|
--replace "/bin/stty" "${coreutils}/bin/stty"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
nativeBuildInputs = [ installShellFiles ];
|
||||||
|
|
||||||
|
preCheck = ''
|
||||||
|
export HOME=$TMPDIR
|
||||||
|
export TF_SKIP_REMOTE_TESTS=1
|
||||||
|
'';
|
||||||
|
|
||||||
|
# https://github.com/posener/complete/blob/9a4745ac49b29530e07dc2581745a218b646b7a3/cmd/install/bash.go#L8
|
||||||
|
completionBash = "complete -C terraform terraform\n";
|
||||||
|
# https://github.com/posener/complete/blob/9a4745ac49b29530e07dc2581745a218b646b7a3/cmd/install/zsh.go
|
||||||
|
completionZsh = "complete -C terraform terraform\n";
|
||||||
|
# https://github.com/posener/complete/blob/9a4745ac49b29530e07dc2581745a218b646b7a3/cmd/install/fish.go#L56
|
||||||
|
completionFish = ''
|
||||||
|
function __complete_terraform
|
||||||
|
set -lx COMP_LINE (commandline -cp)
|
||||||
|
test -z (commandline -ct)
|
||||||
|
and set COMP_LINE "$COMP_LINE "
|
||||||
|
terraform
|
||||||
|
end
|
||||||
|
complete -f -c terraform -a "(__complete_terraform)"
|
||||||
|
'';
|
||||||
|
|
||||||
|
passAsFile = [ "completionBash" "completionZsh" "completionFish" ];
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
# remove all plugins, they are part of the main binary now
|
# remove all plugins, they are part of the main binary now
|
||||||
for i in $out/bin/*; do
|
for i in $out/bin/*; do
|
||||||
|
@ -41,32 +68,19 @@ let
|
||||||
rm "$i"
|
rm "$i"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
installShellCompletion --bash --name terraform $completionBashPath
|
||||||
|
installShellCompletion --zsh --name terraform $completionZshPath
|
||||||
|
installShellCompletion --fish --name terraform $completionFishPath
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preCheck = ''
|
meta = {
|
||||||
export HOME=$TMPDIR
|
|
||||||
export TF_SKIP_REMOTE_TESTS=1
|
|
||||||
'';
|
|
||||||
|
|
||||||
subPackages = [ "." ];
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description =
|
description =
|
||||||
"Tool for building, changing, and versioning infrastructure";
|
"Tool for building, changing, and versioning infrastructure";
|
||||||
homepage = "https://www.terraform.io/";
|
homepage = "https://www.terraform.io/";
|
||||||
changelog = "https://github.com/hashicorp/terraform/blob/v${version}/CHANGELOG.md";
|
changelog = "https://github.com/hashicorp/terraform/blob/v${version}/CHANGELOG.md";
|
||||||
license = licenses.mpl20;
|
license = lib.licenses.mpl20;
|
||||||
maintainers = with maintainers; [
|
maintainers = with lib.maintainers; [ Chili-Man babariviere kalbasit marsam maxeaubrey techknowlogick timstott zimbatm zowoq ];
|
||||||
Chili-Man
|
|
||||||
babariviere
|
|
||||||
kalbasit
|
|
||||||
marsam
|
|
||||||
maxeaubrey
|
|
||||||
timstott
|
|
||||||
zimbatm
|
|
||||||
zowoq
|
|
||||||
techknowlogick
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
} // attrs');
|
} // attrs');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue