lima: fix cross

Only try to generate shell completions if the executables can be run
This commit is contained in:
Stefan Frijters 2024-11-16 21:15:46 +01:00
parent 32fc989515
commit 711b9bd4c8
No known key found for this signature in database
GPG Key ID: 7619A6BC6E7DFA6F
2 changed files with 4 additions and 2 deletions

View File

@ -57,7 +57,7 @@ stdenvNoCC.mkDerivation {
chmod +x $out/bin/limactl chmod +x $out/bin/limactl
wrapProgram $out/bin/limactl \ wrapProgram $out/bin/limactl \
--prefix PATH : ${lib.makeBinPath [ qemu ]} --prefix PATH : ${lib.makeBinPath [ qemu ]}
'' + lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) ''
# the shell completion only works with a patched $out/bin/limactl and so # the shell completion only works with a patched $out/bin/limactl and so
# needs to run after the autoPatchelfHook is executed in postFixup. # needs to run after the autoPatchelfHook is executed in postFixup.
doShellCompletion() { doShellCompletion() {
@ -67,7 +67,7 @@ stdenvNoCC.mkDerivation {
--zsh <($out/bin/limactl completion zsh) --zsh <($out/bin/limactl completion zsh)
} }
postFixupHooks+=(doShellCompletion) postFixupHooks+=(doShellCompletion)
'' + ''
runHook postInstall runHook postInstall
''; '';

View File

@ -54,10 +54,12 @@ buildGoModule rec {
cp -r _output/* $out cp -r _output/* $out
wrapProgram $out/bin/limactl \ wrapProgram $out/bin/limactl \
--prefix PATH : ${lib.makeBinPath [ qemu ]} --prefix PATH : ${lib.makeBinPath [ qemu ]}
'' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd limactl \ installShellCompletion --cmd limactl \
--bash <($out/bin/limactl completion bash) \ --bash <($out/bin/limactl completion bash) \
--fish <($out/bin/limactl completion fish) \ --fish <($out/bin/limactl completion fish) \
--zsh <($out/bin/limactl completion zsh) --zsh <($out/bin/limactl completion zsh)
'' + ''
runHook postInstall runHook postInstall
''; '';