bun: install completions

Co-authored-by: Weijia Wang <9713184+wegank@users.noreply.github.com>
This commit is contained in:
Ryan Cao 2023-09-09 11:44:48 +08:00 committed by Yt
parent 9302a9ce70
commit 92f31b5b7c

View File

@ -3,6 +3,7 @@
, fetchurl
, autoPatchelfHook
, unzip
, installShellFiles
, openssl
, writeShellScript
, curl
@ -17,7 +18,7 @@ stdenvNoCC.mkDerivation rec {
src = passthru.sources.${stdenvNoCC.hostPlatform.system} or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");
strictDeps = true;
nativeBuildInputs = [ unzip ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ];
nativeBuildInputs = [ unzip installShellFiles ] ++ lib.optionals stdenvNoCC.isLinux [ autoPatchelfHook ];
buildInputs = [ openssl ];
dontConfigure = true;
@ -31,6 +32,21 @@ stdenvNoCC.mkDerivation rec {
runHook postInstall
'';
postPhases = [ "postPatchelf" ];
postPatchelf = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
completions_dir=$(mktemp -d)
SHELL="bash" $out/bin/bun completions $completions_dir
SHELL="zsh" $out/bin/bun completions $completions_dir
SHELL="fish" $out/bin/bun completions $completions_dir
installShellCompletion --name bun \
--bash $completions_dir/bun.completion.bash \
--zsh $completions_dir/_bun \
--fish $completions_dir/bun.fish
'';
passthru = {
sources = {
"aarch64-darwin" = fetchurl {