NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.43k stars 12.92k forks source link

vscode-extensions: add 40K VSCode extensions #208456

Open deemp opened 1 year ago

deemp commented 1 year ago

Packaging request

Hi! I'd like to incorporate 40K VSCode extensions into nixpkgs. Please, help me do this if you find this idea OK.

VSCode extensions

There are available via APIs approx. 40K extensions for VSCode on vscode-marketplace and approx. 2K on open-vsx. @AmeerTaweel and me made a GH action to write Nix expressions for them into a flake. See the repo. The action is pretty stable and runs daily.

Use case

I got used to providing VSCodium with extensions on a per-project basis. That is, VSCodium for each of the projects has another set of extensions.

There is a template that you may try. Sometimes, it's necessary to reboot the system for VSCodium to see the extensions.

Note

UPD

We got a permission to access VS Marketplace. See comment

UPD 1

To calculate a SHA of an extension, we have to download it via nix. So, we have to obtain the Offerings. It is permitted in case of our action. I asked if the users of our flake may access the Marketplace API when evaluating our flake. See the comment.

Terms of use

According to the VSCode Marketplace Terms of Use "You may not access, search, obtain or attempt to obtain any Offerings, materials, or information through any means other than Microsoft’s publicly supported interfaces (including, without limitation, through automated harvesting, ‘spidering’ or ‘scraping’ the Marketplace)."

We use nvfetcher to generate expressions for extensions. So, hopefully, we obtain no Offerings but rather info about them. And we obtain such info via a publicly available Marketplace API.

An example of what we get:

dbaeumer-vscode-eslint = {
    pname = "dbaeumer-vscode-eslint";
    version = "2.3.0";
    src = fetchurl {
      url = "https://dbaeumer.gallery.vsassets.io/_apis/public/gallery/publisher/dbaeumer/extension/vscode-eslint/2.3.0/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage";
      name = "vscode-eslint-2.3.0.zip";
      sha256 = "sha256-fR/glHPANL1Jg7rN3Dfzw3+ISiTXb+pWvj0sqgpYGS0=";
    };
    name = "vscode-eslint";
    marketplacePublisher = "dbaeumer";
    marketplaceName = "vscode-eslint";
    publisher = "dbaeumer";
  };
Atemu commented 1 year ago

You may not access, search, obtain or attempt to obtain any Offerings, materials, or information through any means other than Microsoft’s publicly supported interfaces (including, without limitation, through automated harvesting, ‘spidering’ or ‘scraping’ the Marketplace).

So, is this API an interface blessed by M$?

deemp commented 1 year ago

@Atemu, IDK. Have just opened an issue https://github.com/microsoft/vsmarketplace/issues/548

deemp commented 1 year ago

After contacting @prashantvc, I got a permission to call the VS Marketplace API in this particular scenario. So, I guess we can now decide how to include that flake.

prashantvc commented 1 year ago

You are good to use this solution 👍

deemp commented 1 year ago

@prashantvc , sorry to bother you about nix-vscode-extensions again. A quick reminder. This is a Nix flake that allows Nix users to get the extensions from Open VSX and VS Marketplace and use them in per-project VSCode setups.

In our flake, we only provide the information about extensions, not the files. Here's what we record about an extension:

{
    "lastUpdated": "2023-01-27T00:13:45.76Z",
    "name": "c0-lsp",
    "publisher": "15122staff",
    "sha256": "sha256-F2/YK4fntexO7uactN1/nzkJ6CQ8TMzbFKml+plUU/c=",
    "url": "https://15122staff.gallery.vsassets.io/_apis/public/gallery/publisher/15122staff/extension/c0-lsp/2.4.0/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage",
    "version": "2.4.0"
}

When a user of our flake wants to get an extension, nix usually requests the Marketplace API via such a URL. For our flake, we stated in the README that users should not abuse this flake.

Am I correct that in this scenario, users of our flake are permitted to call the Markeplace API via nix?