diff --git a/pkgs/tools/networking/sing-box/default.nix b/pkgs/tools/networking/sing-box/default.nix index 731b880af29d..99d320f4f85c 100644 --- a/pkgs/tools/networking/sing-box/default.nix +++ b/pkgs/tools/networking/sing-box/default.nix @@ -1,6 +1,9 @@ { lib +, stdenv , buildGoModule , fetchFromGitHub +, installShellFiles +, buildPackages }: buildGoModule rec { @@ -33,6 +36,15 @@ buildGoModule rec { "cmd/sing-box" ]; + nativeBuildInputs = [ installShellFiles ]; + + postInstall = let emulator = stdenv.hostPlatform.emulator buildPackages; in '' + installShellCompletion --cmd sing-box \ + --bash <(${emulator} $out/bin/sing-box completion bash) \ + --fish <(${emulator} $out/bin/sing-box completion fish) \ + --zsh <(${emulator} $out/bin/sing-box completion zsh ) + ''; + meta = with lib;{ homepage = "https://sing-box.sagernet.org"; description = "The universal proxy platform";