nix: add clap completions
Some checks failed
Build and test / check (push) Failing after 39s
Build and test / build (push) Successful in 1m38s
Build and test / test (push) Has been cancelled
Build and test / docs (push) Has been cancelled

This commit is contained in:
2026-01-09 05:16:12 +09:00
parent 6c3a9e9e12
commit 34803c2b1f
5 changed files with 61 additions and 2 deletions

View File

@@ -2,6 +2,7 @@
lib
, rustPlatform
, stdenv
, buildPackages
, installShellFiles
, versionCheckHook
@@ -20,6 +21,21 @@ rustPlatform.buildRustPackage {
RUSTFLAGS = "-Zhigher-ranked-assumptions";
nativeBuildInputs = [ installShellFiles ];
postInstall = let
emulator = stdenv.hostPlatform.emulator buildPackages;
installShellCompletions = lib.mapCartesianProduct ({ shell, command }: ''
(
export PATH="$out/bin:$PATH"
"${emulator}" "${command}" --completions=${shell} > "$TMP/${command}.${shell}"
)
installShellCompletion "--${shell}" --cmd "${command}" "$TMP/${command}.${shell}"
'') {
shell = [ "bash" "zsh" "fish" ];
command = [ "rwho" "ruptime" ];
};
in lib.concatStringsSep "\n" installShellCompletions;
meta = with lib; {
license = licenses.mit;
platforms = platforms.linux ++ platforms.darwin;