NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.16k stars 13.42k forks source link

update_installed_exts.sh: Script also includes extensions installed from nixpkgs directly #199896

Open TibiIius opened 1 year ago

TibiIius commented 1 year ago

Describe the bug

When running the update_installed_exts.sh script, extensions that are installed via nixpkgs directly rather than fetched from the marketplace (i.e. using nixpkgs.vscode-extensions.${EXTENSION} instead of nixpkgs.vscode-utils.extensionsFromVscodeMarketplace) are getting listed in the output as well. This is problematic, as extensions sometimes need patches, hooks or similar to work properly, which are not applied when installed via the marketplace. If extensions are present in both nixpkgs.vscode-extensions and nixpkgs.vscode-utils.extensionsFromVscodeMarketplace, building VSCode will fail as both versions are conflicting.

Steps To Reproduce

  1. Have one or more VSCode extensions installed via nixpkgs.vscode-extensions.
  2. Run nixpkgs/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh.
  3. See the extensions installed via nixpkgs.vscode-extensions in the script's output as well.

Expected behavior

Extensions which are available via nixpkgs.vscode-extensions should not be included in the output of update_installed_exts.sh, or at least there should be a switch to exclude them (so that users can still decide between getting all their extensions from marketplace or only the ones not provided by nixpkgs directly).

Additional context

The reason for why this is a problem at all is that some extensions require specific patches, workarounds, hooks etc. to work properly or at all, as noted above already. One example would be rust-analyzer, which only works properly when installed via nixpkgs.vscode-extensions.matklad.rust-analyzer. If fetched from VSCode's marketplace directly, the extensions tries to load the default shipped binary at $HOME/.vscode/extensions/rust-lang.rust-analyzer/server/rust-analyzer instead of the one in /nix/store, which then fails. I haven't yet tried any other extensions, so I don't know if there are any other extensions which share a similar problem. Nevertheless, the current behavior should be adjusted to prevent future problems and fix other possibly existing ones.

If important, my configuration files are based on unstable, and I'm configuring VSCode via home-manager.

Notify maintainers

I don't really know who to mention here. The last person who touched the script only refactored the directory layout the script resides in, and except for the original author, all other edits were really small, so I suppose mentioning the original author makes the most sense. @mankyKitty

Metadata

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.0.6-arch1-1, Arch Linux, noversion, rolling`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - channels(tim): `"home-manager, nixgl, nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/tim/channels/nixpkgs`
mankyKitty commented 1 year ago

That's a definite limitation and one I solved locally using weak hack. If' I'm able to work out how to query for the packages under that path then it shouldn't be too difficult a change to make. (famous last words) ... This might push things over the edge into something that shouldn't use bash. ahem