Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode-with-extensions: fix insiders build #71251

Merged
merged 1 commit into from Mar 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkgs/applications/editors/vscode/with-extensions.nix
Expand Up @@ -48,7 +48,7 @@ let
wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" vscode.name;

combinedExtensionsDrv = buildEnv {
name = "${wrappedPkgName}-extensions-${wrappedPkgVersion}";
name = "vscode-extensions";
paths = vscodeExtensions;
};

Expand All @@ -70,6 +70,6 @@ runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" {
ln -sT "${vscode}/share/applications/${executableName}.desktop" "$out/share/applications/${executableName}.desktop"
ln -sT "${vscode}/share/applications/${executableName}-url-handler.desktop" "$out/share/applications/${executableName}-url-handler.desktop"
makeWrapper "${vscode}/bin/${executableName}" "$out/bin/${executableName}" ${lib.optionalString (vscodeExtensions != []) ''
--add-flags "--extensions-dir ${combinedExtensionsDrv}/share/${wrappedPkgName}/extensions"
--add-flags "--extensions-dir ${combinedExtensionsDrv}"
''}
''
10 changes: 3 additions & 7 deletions pkgs/misc/vscode-extensions/vscode-utils.nix
@@ -1,9 +1,6 @@
{ stdenv, lib, fetchurl, vscode, unzip }:
{ stdenv, lib, fetchurl, unzip }:

let
extendedPkgVersion = lib.getVersion vscode;
extendedPkgName = lib.removeSuffix "-${extendedPkgVersion}" vscode.name;

mktplcExtRefToFetchArgs = ext: {
url = "https://${ext.publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${ext.publisher}/extension/${ext.name}/${ext.version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage";
sha256 = ext.sha256;
Expand All @@ -14,7 +11,6 @@ let

buildVscodeExtension = a@{
name,
namePrefix ? "${extendedPkgName}-extension-",
src,
# Same as "Unique Identifier" on the extension's web page.
# For the moment, only serve as unique extension dir.
Expand All @@ -28,12 +24,12 @@ let
}:
stdenv.mkDerivation ((removeAttrs a [ "vscodeExtUniqueId" ]) // {

name = namePrefix + name;
name = "vscode-extension-${name}";

inherit vscodeExtUniqueId;
inherit configurePhase buildPhase dontPatchELF dontStrip;

installPrefix = "share/${extendedPkgName}/extensions/${vscodeExtUniqueId}";
installPrefix = "${vscodeExtUniqueId}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What bothers me is that now, an extension no longer stand as a standard package which could simply be installed in an environment using nix-env. It this really a use case, I'm not sure.

In case we want to treat those extensions as standalone packages, stuff like this really should end up under the lfs share folder and the namespace under share being fairly unique. It was the approach taken by vim plugins which I initially took inspiration from.

It might even end up being required by licenses to expose the source code / files when installing vscode-with-extensions/vscodium-with-extensions/etc (is it?).

How about instead just outputting those under something more straigtforward such as: share/vscode/extensions/${vscodeExtUniqueId} regardless of the wrapped executable? This is what has been suggested in #76494.

Note that this is not a strong opinion. Anyone else interested in providing more insight?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good point! However that isn't a perfect solution, since Insiders versions of VSCode need their extensions to be in an appropriately named directory.
I wonder how many people actually use Nix-managed extensions but do not use them via vscode-with-extensions, but I agree that it's good to support it on principle.
My suggestion is that we have the extension derivations like they are now, and provide versions of them that have been symlinked to the appropriate place that people can use. This means the path could be varied depending on whether they use an Insiders version or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insiders versions of VSCode need their extensions to be in an appropriately named directory.

I'm not sure to quite understand in what regards the current PR changes that and what exactly is the distinction in terms of extension location?


buildInputs = [ unzip ] ++ buildInputs;

Expand Down