Vscode extensions not works with shell.nix

Vscode extension not working using shell.nix

{ pkgs ? import <nixpkgs> { config.allowUnfree = true; } }:
#{ pkgs ? import (fetchTarball  "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05") {} }:
let
  message = "Lets Start Development";
in 

#nixpkgs.config.allowUnfree = true;

pkgs.mkShellNoCC {
  buildInputs = with pkgs; [ nodejs ];


  packages = with pkgs; [
    nodejs_22
    nodePackages.browser-sync 
    nodePackages.nodemon 
    vscodium
    vscode
    vscode-extensions.github.copilot
    vscode-extensions.github.copilot-chat
    firefox
    vim 
    curl     
  ];

  shellHook = ''
    cowsay ${message}
    export NIXPKGS_ALLOW_UNFREE=1	
    export DONT_PROMPT_WSL_INSTALL=1	
    npm run dev & echo "y" | code . & firefox localhost:3000 & npm run dev & firefox 127.0.0.1:5501
    code .
    '';
}

Try vscode-with-extensions as described in the unofficial wiki. Also remove the standalone vscode and vscodium from the shell definition.

This code works

but it seems quiet complex

{ pkgs ? import <nixpkgs> { allowUnfree = true; } }:
#{ pkgs ? import (fetchTarball  "https://github.com/NixOS/nixpkgs/nixos-24.05") {} }:
let
  message = "Lets Start Development";
in 





pkgs.mkShellNoCC {
  buildInputs = with pkgs; [ 
	vscode-with-extensions 
	vscode-extensions.github.copilot
	vscode-extensions.github.copilot-chat		
];

  packages = with pkgs; [
    vscodium
    vim 
    curl 
  (vscode-with-extensions.override {
    vscodeExtensions = with vscode-extensions; [
      	github.copilot
	github.copilot-chat
	bbenoist.nix
      ms-python.python
      ms-azuretools.vscode-docker
      ms-vscode-remote.remote-ssh
    ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
      {
        name = "remote-ssh-edit";
        publisher = "ms-vscode-remote";
        version = "0.47.2";
        sha256 = "1hp6gjh4xp2m1xlm1jsdzxw9d8frkiidhph6nvl24d0h8z34w49g";
      }
    ];
  })
    
  ];

  shellHook = ''
    cowsay ${message}
    echo "y" | code .
    '';
}

You can make it less verbose by removing buildInputs, it just duplicates the stuff you already have in packages. And I don’t think you need vscodium in packages if you already have vscode-with-extensions?

You can also refactor it to be cleaner, e.g.:

let myVscode = pkgs.vscode-with-extensions.override {
/* ... */
};
in
pkgs.mkShellNoCC {
  packages = [
    myVscode
    /* ... */
  ];
}