Make nodejs available just for jetbrain's webstorm

Webstorm needs nodejs available but I don’t want to install it as home.packages so I tried (jetbrains.webstorm.override { buildInputs = [ nodejs ]; }) but it doesn’t work are there any other options?

This is what ChatGPT recommends but I feel there should be something as simple as the buildInputs I tried.

{ pkgs }:

let
  webstormWithNode = pkgs.mkDerivation {
    name = "webstorm-with-node";
    buildInputs = [ pkgs.jetbrains.webstorm pkgs.nodejs ];
    src = pkgs.null;
    phases = [ "installPhase" ];
    installPhase = ''
      mkdir -p $out/bin
      ln -s ${pkgs.jetbrains.webstorm}/bin/webstorm.sh $out/bin/webstorm
    '';
  };
in
{
  environment.systemPackages = [ webstormWithNode ];
}

also if its the way should I do it as overlay or no?

Sorry, but I don’t see why the proposed fix would work at all. I don’t see the nodejs being added to the intellithings PATH.

Personally I’d use runCommand and wrapProgram to augment the PATH.

Something like this:

runCommand "webstorm-with-node" {nativeBuildInputs = [makeWrapper];} ''
  mkdir -p $out/bin
  makeWrapper ${jetbrains.webstorm}/bin/webstorm $out/bin/webstorm \
    --prefix PATH : ${lib.makeBinPath [ nodejs ]}
''

That changes the way I would need to launch webstorm right? I would like to keep webstorm entry working in gnome launcher thats why I tried to “patch” it via override.

Then also copy/link the desktop file…

The principle is really the same as I did for wrapping GnuCash, you want just a different variable to be augmented, and the filenames might be a bit different.


Alternatively, if the rebuild really is not an issue for you, then doing the wrapping in postInstall of an overrideAttrs might work as well. But I haven’t looked into the derivations code to say that for sure.

1 Like