nix-community / nix-vscode-extensions

Nix expressions for VSCode and OpenVSX extensions [maintainers: @deemp, @AmeerTaweel]
MIT License
234 stars 13 forks source link

Multiple directories #31

Closed jcszymansk closed 1 year ago

jcszymansk commented 1 year ago

The Netbeans extension (asf.apache-netbeans-java), possibly others, have multiple directories in the zipfile, and this causes the build to fail:

error: builder for '/nix/store/spmw2bry62skgchvpb6qkk8rf926r745-vscode-extension-asf-apache-netbeans-java-18.0.0.drv' failed with exit code 1;
       last 3 log lines:
       > unpacking sources
       > unpacking source archive /nix/store/rqpc0q8117cy5jcn8hhd84vk92006icd-apache-netbeans-java-18.0.0.zip
       > unpacker produced multiple directories
jcszymansk commented 1 year ago

Found a workaround:

(asf.apache-netbeans-java.overrideAttrs (_: { sourceRoot = "extension"; }))
deemp commented 1 year ago

We fetch extensions as .zip archives that get unpacked when building an extension derivation. The sourceRoot attribute (see the nixpkgs manual) of an extension derivation affects the unpackPhase of the derivation.

jcszymansk commented 1 year ago

This much I figured out, indeed it was where I took this sourceRoot from. Now I think how it would be possible to - in a way similar to what is being done with Intellij plugins, see here - have some specialExts.nix file where extensions that need special treatment, like the Netbeans one, would receive it.

I'll look into it and hopefully come back with a pull request.

deemp commented 1 year ago

@jacekszymanski, I found a way to provide overrides. See https://github.com/nix-community/nix-vscode-extensions#special-extensions

jcszymansk commented 1 year ago

Great! So I think I can close this issue now :+1:

deemp commented 1 year ago

@jacekszymanski, please, check that it works. I have a quite slow Internet connection and can't nix build.

UPD: it finally worked!

jcszymansk commented 1 year ago

Yes, I can confirm it works.

FraGag commented 9 months ago

Extension ms-vscode.cmake-tools recently started to fail to build as well. Version 1.17.14 builds fine, but versions 1.17.15 and up fail.

# Version 1.17.14 (succeeds)
nix build github:nix-community/nix-vscode-extensions/856a8c1902513fa72f86963bd9f3c9238828c23a#extensions.x86_64-linux.vscode-marketplace.ms-vscode.cmake-tools

# Version 1.17.15 (fails)
nix build github:nix-community/nix-vscode-extensions/f495145caabb9a3b5bb3ae2815a66db1c3fbe31d#extensions.x86_64-linux.vscode-marketplace.ms-vscode.cmake-tools

Since 1.17.15, the .vsix contains additional _rels and package directories, which appear to contain a digital signature for the extension.

The workaround described in https://github.com/nix-community/nix-vscode-extensions/issues/31#issuecomment-1636838281 works, but considering that .vsix files have a fixed structure, I thought, "Why not just set sourceRoot = "extension"; for all extensions?" So I went ahead and submitted https://github.com/NixOS/nixpkgs/pull/289721 to nixpkgs, since nix-vscode-extensions is relying on vscode-utils from nixpkgs to define the derivations for VSCode extensions.

jcszymansk commented 9 months ago

I'm not sure whether the extension directory must be named extension, have you found it documented anywhere?

From what I remember the .vsix has a manifest file that points at a package.json which in most (all?) extensions happens to be in an extension directory, but I didn't find out then whether it is a documented subdirectory or a default build packaging which some extensions might not follow?

FraGag commented 9 months ago

Hmm, no, truthfully I just assumed. I used nixpkgs-review on my change and all VSCode extensions defined in nixpkgs built successfully, but there could be extensions that ended up empty, I suppose, I didn't check... If everybody is publishing extensions the same way though, then in practice every .vsix should have the extension in extension. In the worst case, we can just override the sourceRoot for the exceptions. :smile: