Merge pull request #28526 from jraygauthier/jrg/vscode-extensions-improvs
vscode-with-extension: improvements
This commit is contained in:
commit
ab3de8ed6c
@ -2,7 +2,7 @@
|
|||||||
, vscodeExtensions ? [] }:
|
, vscodeExtensions ? [] }:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
`vsixExtensions`
|
`vscodeExtensions`
|
||||||
: A set of vscode extensions to be installed alongside the editor. Here's a an
|
: A set of vscode extensions to be installed alongside the editor. Here's a an
|
||||||
example:
|
example:
|
||||||
|
|
||||||
@ -10,12 +10,12 @@
|
|||||||
vscode-with-extensions.override {
|
vscode-with-extensions.override {
|
||||||
|
|
||||||
# When the extension is already available in the default extensions set.
|
# When the extension is already available in the default extensions set.
|
||||||
vscodeExtensions = with vscodeExtensions; [
|
vscodeExtensions = with vscode-extensions; [
|
||||||
nix
|
bbenoist.Nix
|
||||||
]
|
]
|
||||||
|
|
||||||
# Concise version from the vscode market place when not available in the default set.
|
# Concise version from the vscode market place when not available in the default set.
|
||||||
++ vscodeUtils.extensionsFromVscodeMarketplace [
|
++ vscode-utils.extensionsFromVscodeMarketplace [
|
||||||
{
|
{
|
||||||
name = "code-runner";
|
name = "code-runner";
|
||||||
publisher = "formulahendry";
|
publisher = "formulahendry";
|
||||||
|
@ -3,16 +3,23 @@
|
|||||||
let
|
let
|
||||||
inherit (vscode-utils) buildVscodeExtension buildVscodeMarketplaceExtension;
|
inherit (vscode-utils) buildVscodeExtension buildVscodeMarketplaceExtension;
|
||||||
in
|
in
|
||||||
|
#
|
||||||
|
# Unless there is a good reason not to, we attemp to use the same name as the
|
||||||
|
# extension's unique identifier (the name the extension gets when installed
|
||||||
|
# from vscode under `~/.vscode`) and found on the marketplace extension page.
|
||||||
|
# So an extension's attribute name should be of the form:
|
||||||
|
# "${mktplcRef.publisher}.${mktplcRef.name}".
|
||||||
|
#
|
||||||
rec {
|
rec {
|
||||||
nix = buildVscodeMarketplaceExtension {
|
bbenoist.Nix = buildVscodeMarketplaceExtension {
|
||||||
mktplcRef = {
|
mktplcRef = {
|
||||||
name = "nix";
|
name = "Nix";
|
||||||
publisher = "bbenoist";
|
publisher = "bbenoist";
|
||||||
version = "1.0.1";
|
version = "1.0.1";
|
||||||
sha256 = "0zd0n9f5z1f0ckzfjr38xw2zzmcxg1gjrava7yahg5cvdcw6l35b";
|
sha256 = "0zd0n9f5z1f0ckzfjr38xw2zzmcxg1gjrava7yahg5cvdcw6l35b";
|
||||||
};
|
};
|
||||||
|
meta = with stdenv.lib; {
|
||||||
# TODO: Fill meta with appropriate information.
|
license = licenses.mit;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{ stdenv, lib, fetchurl, runCommand, vscode, which }:
|
{ stdenv, lib, fetchurl, runCommand, vscode, unzip }:
|
||||||
|
|
||||||
let
|
let
|
||||||
extendedPkgVersion = lib.getVersion vscode;
|
extendedPkgVersion = lib.getVersion vscode;
|
||||||
@ -7,13 +7,18 @@ let
|
|||||||
mktplcExtRefToFetchArgs = ext: {
|
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";
|
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;
|
sha256 = ext.sha256;
|
||||||
name = "${ext.name}.vsix";
|
# The `*.vsix` file is in the end a simple zip file. Change the extension
|
||||||
|
# so that existing `unzip` hooks takes care of the unpacking.
|
||||||
|
name = "${ext.publisher}-${ext.name}.zip";
|
||||||
};
|
};
|
||||||
|
|
||||||
buildVscodeExtension = a@{
|
buildVscodeExtension = a@{
|
||||||
name,
|
name,
|
||||||
namePrefix ? "${extendedPkgName}-extension-",
|
namePrefix ? "${extendedPkgName}-extension-",
|
||||||
src,
|
src,
|
||||||
|
# Same as "Unique Identifier" on the extension's web page.
|
||||||
|
# For the moment, only serve as unique extension dir.
|
||||||
|
vscodeExtUniqueId,
|
||||||
configurePhase ? ":",
|
configurePhase ? ":",
|
||||||
buildPhase ? ":",
|
buildPhase ? ":",
|
||||||
dontPatchELF ? true,
|
dontPatchELF ? true,
|
||||||
@ -21,35 +26,18 @@ let
|
|||||||
buildInputs ? [],
|
buildInputs ? [],
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
stdenv.mkDerivation (a // {
|
stdenv.mkDerivation ((removeAttrs a [ "vscodeExtUniqueId" ]) // {
|
||||||
|
|
||||||
name = namePrefix + name;
|
name = namePrefix + name;
|
||||||
|
|
||||||
|
inherit vscodeExtUniqueId;
|
||||||
inherit configurePhase buildPhase dontPatchELF dontStrip;
|
inherit configurePhase buildPhase dontPatchELF dontStrip;
|
||||||
|
|
||||||
# TODO: `which` is an encapsulation leak. It should have been hardwired
|
buildInputs = [ unzip ] ++ buildInputs;
|
||||||
# as part of the `code` wrapper.
|
|
||||||
buildInputs = [ vscode which ] ++ buildInputs;
|
|
||||||
|
|
||||||
unpackPhase = ''
|
|
||||||
# TODO: Unfortunately, 'code' systematically creates its '.vscode' directory
|
|
||||||
# even tough it has nothing to write in it. We need to redirect this
|
|
||||||
# to a writeable location as the nix environment already has (but
|
|
||||||
# to a non writeable one) otherwise the write will fail.
|
|
||||||
# It would be preferrable if we could intercept / fix this at the source.
|
|
||||||
HOME="$PWD/code_null_home" code \
|
|
||||||
--extensions-dir "$PWD" \
|
|
||||||
--install-extension "${toString src}"
|
|
||||||
|
|
||||||
rm -Rf "$PWD/code_null_home"
|
|
||||||
cd "$(find . -mindepth 1 -type d -print -quit)"
|
|
||||||
ls -la
|
|
||||||
'';
|
|
||||||
|
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p "$out/share/${extendedPkgName}/extensions/${name}"
|
mkdir -p "$out/share/${extendedPkgName}/extensions/${vscodeExtUniqueId}"
|
||||||
find . -mindepth 1 -maxdepth 1 | xargs mv -t "$out/share/${extendedPkgName}/extensions/${name}/"
|
find . -mindepth 1 -maxdepth 1 | xargs mv -t "$out/share/${extendedPkgName}/extensions/${vscodeExtUniqueId}/"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -65,8 +53,9 @@ let
|
|||||||
...
|
...
|
||||||
}: assert "" == name; assert null == src;
|
}: assert "" == name; assert null == src;
|
||||||
buildVscodeExtension ((removeAttrs a [ "mktplcRef" ]) // {
|
buildVscodeExtension ((removeAttrs a [ "mktplcRef" ]) // {
|
||||||
name = "${mktplcRef.name}-${mktplcRef.version}";
|
name = "${mktplcRef.publisher}-${mktplcRef.name}-${mktplcRef.version}";
|
||||||
src = fetchVsixFromVscodeMarketplace mktplcRef;
|
src = fetchVsixFromVscodeMarketplace mktplcRef;
|
||||||
|
vscodeExtUniqueId = "${mktplcRef.publisher}.${mktplcRef.name}";
|
||||||
});
|
});
|
||||||
|
|
||||||
mktplcRefAttrList = [
|
mktplcRefAttrList = [
|
||||||
|
Loading…
Reference in New Issue
Block a user