argc: support cross-compilation
Use native argc to generate shell completion files when "$out/bin/argc" cannot be executed on the build platform.
This commit is contained in:
parent
0a58c62f7d
commit
60949c89cd
@ -1,10 +1,15 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
|
buildPackages,
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
|
stdenv,
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
installShellFiles,
|
installShellFiles,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
canExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform;
|
||||||
|
in
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "argc";
|
pname = "argc";
|
||||||
version = "1.14.0";
|
version = "1.14.0";
|
||||||
@ -18,15 +23,19 @@ rustPlatform.buildRustPackage rec {
|
|||||||
|
|
||||||
cargoHash = "sha256-D1T9FWTvwKtAYoqFlR2OmLRLGWhPJ9D8J7lq/QKcBoM=";
|
cargoHash = "sha256-D1T9FWTvwKtAYoqFlR2OmLRLGWhPJ9D8J7lq/QKcBoM=";
|
||||||
|
|
||||||
nativeBuildInputs = [ installShellFiles ];
|
nativeBuildInputs = [ installShellFiles ] ++ lib.optional (!canExecuteHost) buildPackages.argc;
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
|
ARGC=${if canExecuteHost then ''''${!outputBin}/bin/argc'' else "argc"}
|
||||||
|
|
||||||
installShellCompletion --cmd argc \
|
installShellCompletion --cmd argc \
|
||||||
--bash <($out/bin/argc --argc-completions bash) \
|
--bash <("$ARGC" --argc-completions bash) \
|
||||||
--fish <($out/bin/argc --argc-completions fish) \
|
--fish <("$ARGC" --argc-completions fish) \
|
||||||
--zsh <($out/bin/argc --argc-completions zsh)
|
--zsh <("$ARGC" --argc-completions zsh)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
disallowedReferences = lib.optional (!canExecuteHost) buildPackages.argc;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Command-line options, arguments and sub-commands parser for bash";
|
description = "Command-line options, arguments and sub-commands parser for bash";
|
||||||
mainProgram = "argc";
|
mainProgram = "argc";
|
||||||
|
Loading…
Reference in New Issue
Block a user