installShellFiles: add emulator doc for installShellCompletion

This commit is contained in:
ZHAO Jin-Xiang 2025-03-16 23:55:35 +08:00
parent d524147f47
commit 149a6e0a91

View File

@ -99,12 +99,17 @@ failure. To prevent this, guard the completion generation commands.
```nix ```nix
{ {
nativeBuildInputs = [ installShellFiles ]; nativeBuildInputs = [ installShellFiles ];
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
# using named fd let
installShellCompletion --cmd foobar \ emulator = stdenv.hostPlatform.emulator buildPackages;
--bash <($out/bin/foobar --bash-completion) \ in
--fish <($out/bin/foobar --fish-completion) \ ''
--zsh <($out/bin/foobar --zsh-completion) # using named fd
''; installShellCompletion --cmd foobar \
--bash <(${emulator} $out/bin/foobar --bash-completion) \
--fish <(${emulator} $out/bin/foobar --fish-completion) \
--zsh <(${emulator} $out/bin/foobar --zsh-completion)
''
);
} }
``` ```