From f8d01a8da313ac470d3871f158f0c9efd29b17df Mon Sep 17 00:00:00 2001 From: superherointj <5861043+superherointj@users.noreply.github.com> Date: Sun, 2 Jun 2024 12:10:11 -0300 Subject: [PATCH] nodejs: add bash shell completion Fixes #316507 --- pkgs/development/web/nodejs/nodejs.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix index 7fef97677b82..106eaabd1e62 100644 --- a/pkgs/development/web/nodejs/nodejs.nix +++ b/pkgs/development/web/nodejs/nodejs.nix @@ -7,6 +7,7 @@ , gnupg , darwin, xcbuild , procps, icu +, installShellFiles }: { enableNpm ? true, version, sha256, patches ? [] } @args: @@ -69,7 +70,7 @@ let buildInputs = lib.optionals stdenv.isDarwin [ CoreServices ApplicationServices ] ++ [ zlib libuv openssl http-parser icu bash ]; - nativeBuildInputs = [ which pkg-config python ] + nativeBuildInputs = [ installShellFiles pkg-config python which ] ++ lib.optionals stdenv.isDarwin [ xcbuild ]; outputs = [ "out" "libv8" ]; @@ -151,6 +152,11 @@ let postInstall = '' HOST_PATH=$out/bin patchShebangs --host $out + ${lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + $out/bin/${self.meta.mainProgram} --completion-bash > ${self.meta.mainProgram}.bash + installShellCompletion ${self.meta.mainProgram}.bash + ''} + ${lib.optionalString (enableNpm) '' mkdir -p $out/share/bash-completion/completions ln -s $out/lib/node_modules/npm/lib/utils/completion.sh \