Vscode extension can't be installed correctly

I use home manager. here is my config:

programs.vscode = {
  enable = true;
  extensions = with pkgs.vscode-extensions; [
      ms-vscode.cpptools
      ms-vscode.cmake-tools
      bbenoist.nix
  ];
};

The problem is, at first, cpptools and cmake work well. But when I add bbenoist.nix, the other two extensions just disapeard. Even I comment bbenoist.nix, I still only get cmake. cpptools can’t come back. I don’t understand what is the situatioin?

And how can I install extension from extensionsFromVscodeMarketplace in HM?
I tried this:

programs.vscode = {
  enable = true;
  extensions = with pkgs.vscode-extensions; [
      ms-vscode.cpptools
  ];++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
      {
        name = "remote-ssh-edit";
        publisher = "ms-vscode-remote";
        version = "0.47.2";
        sha256 = "1hp6gjh4xp2m1xlm1jsdzxw9d8frkiidhph6nvl24d0h8z34w49g";
      }
    ];
};

but it doesn’t work, there is error. I forgot what it was, I am not at my nix computer now.

Do you install extensions exclusively via Nix? Or do you also use the marketplace?

now I only want to install ms-vscode.cpptools, ms-vscode.cmake-tools, bbenoist.nix.
So now I am only using nixpkgs. But still they kinda collision with each other.
But I may want to install from marketplace later.

What you could try is just kill all the temporary files that vscode places in various directories. Maybe something there is causing this. Obviously some of your config might be gone as well then (unless you use nix to set it, or back it up beforehand).

I had weird issues just like that a while ago. But I don’t use these specific extensions right now. So I don’t know if that was the same problem or not.

];++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
to ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [

[ ... ] ++ [ ... ];

(without ;)

For reference:

{ pkgs, lib, ... }:

let
  USER_NAME = "abc";

  VSCODE_SETTINGS = ./files/vscode.settings.json;
in
{
  environment.systemPackages = with pkgs; [
    vscodium
  ];

  home-manager = {
    useGlobalPkgs = true;

    users.${USER_NAME} = {
      home = {
        stateVersion = "24.05";

        file = lib.mkMerge [
          # adding pre-defined `settings.json` for VSCODE config
          {
            ".config/${pkgs.vscodium.longName}/User/settings.json" = {
              source = VSCODE_SETTINGS;
            };
          }
        ];
      };

      programs = {
        vscode = {
          enable = true;
          package = pkgs.vscodium;

          extensions = with pkgs.vscode-extensions; [
            # https://marketplace.visualstudio.com/items?itemName=bbenoist.Nix
            bbenoist.nix
            # https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
            esbenp.prettier-vscode
            # https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml
            jebbs.plantuml
          ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
            {
              # https://marketplace.visualstudio.com/items?itemName=bogem.bogems-night-owl
              name = "bogems-night-owl";
              publisher = "bogem";
              version = "1.2.0";
              sha256 = "sha256-JpnrebM7C3dRQDaP7FiBwKIZvpQmR/igbe5AXYJviPA";
            }
          ];
        };
      };
    };
  };
}

image

Is there anything wrong with using vscode-fhs?

I know it’s not the NixOS way, but the alternative for me would be to run VSCode out from an OCI container otherwise until I figure out how to install the few missing extensions I need.