diff options
author | Yueh-Shun Li <shamrocklee@posteo.net> | 2024-04-21 05:00:56 +0800 |
---|---|---|
committer | Yueh-Shun Li <shamrocklee@posteo.net> | 2024-05-04 03:28:10 +0800 |
commit | 60949c89cd88cc104a794e6a39dd89ff8593d8c5 (patch) | |
tree | 89a4aaa072cec4f62b7b3433390fbf7c02804452 /pkgs/by-name/ar | |
parent | 0a58c62f7d5bdb61ad8f6903ec3ea3c44a384d8c (diff) |
argc: support cross-compilation
Use native argc to generate shell completion files when "$out/bin/argc" cannot be executed on the build platform.
Diffstat (limited to 'pkgs/by-name/ar')
-rw-r--r-- | pkgs/by-name/ar/argc/package.nix | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/pkgs/by-name/ar/argc/package.nix b/pkgs/by-name/ar/argc/package.nix index 6f62160048b9d..dc7d565d93e16 100644 --- a/pkgs/by-name/ar/argc/package.nix +++ b/pkgs/by-name/ar/argc/package.nix @@ -1,10 +1,15 @@ { lib, + buildPackages, rustPlatform, + stdenv, fetchFromGitHub, installShellFiles, }: +let + canExecuteHost = stdenv.buildPlatform.canExecute stdenv.hostPlatform; +in rustPlatform.buildRustPackage rec { pname = "argc"; version = "1.14.0"; @@ -18,15 +23,19 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-D1T9FWTvwKtAYoqFlR2OmLRLGWhPJ9D8J7lq/QKcBoM="; - nativeBuildInputs = [ installShellFiles ]; + nativeBuildInputs = [ installShellFiles ] ++ lib.optional (!canExecuteHost) buildPackages.argc; postInstall = '' + ARGC=${if canExecuteHost then ''''${!outputBin}/bin/argc'' else "argc"} + installShellCompletion --cmd argc \ - --bash <($out/bin/argc --argc-completions bash) \ - --fish <($out/bin/argc --argc-completions fish) \ - --zsh <($out/bin/argc --argc-completions zsh) + --bash <("$ARGC" --argc-completions bash) \ + --fish <("$ARGC" --argc-completions fish) \ + --zsh <("$ARGC" --argc-completions zsh) ''; + disallowedReferences = lib.optional (!canExecuteHost) buildPackages.argc; + meta = with lib; { description = "Command-line options, arguments and sub-commands parser for bash"; mainProgram = "argc"; |