Merge pull request #210358 from ncfavier/vscode-toExtensionJson

This commit is contained in:
Naïm Favier 2023-01-17 11:50:52 +01:00 committed by GitHub
commit 0303fd9441
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 39 deletions

View file

@ -90,7 +90,6 @@ let
vscodeDefault = vscode;
};
vscodeExts2nix = import ./vscodeExts2nix.nix {
inherit lib writeShellScriptBin;
vscodeDefault = vscode;
@ -100,10 +99,41 @@ let
inherit lib buildEnv writeShellScriptBin extensionsFromVscodeMarketplace jq;
vscodeDefault = vscode;
};
toExtensionJsonEntry = ext: rec {
identifier = {
id = ext.vscodeExtUniqueId;
uuid = "";
};
version = ext.version;
location = {
"$mid" = 1;
fsPath = ext.outPath + "/share/vscode/extensions/${ext.vscodeExtUniqueId}";
path = location.fsPath;
scheme = "file";
};
metadata = {
id = "";
publisherId = "";
publisherDisplayName = ext.vscodeExtPublisher;
targetPlatform = "undefined";
isApplicationScoped = false;
updated = false;
isPreReleaseVersion = false;
installedTimestamp = 0;
preRelease = false;
};
};
toExtensionJson = extensions: builtins.toJSON (map toExtensionJsonEntry extensions);
in
{
inherit fetchVsixFromVscodeMarketplace buildVscodeExtension
buildVscodeMarketplaceExtension extensionFromVscodeMarketplace
extensionsFromVscodeMarketplace
vscodeWithConfiguration vscodeExts2nix vscodeEnv;
vscodeWithConfiguration vscodeExts2nix vscodeEnv
toExtensionJsonEntry toExtensionJson;
}

View file

@ -1,4 +1,4 @@
{ lib, stdenv, runCommand, buildEnv, vscode, makeWrapper, writeText
{ lib, stdenv, runCommand, buildEnv, vscode, vscode-utils, makeWrapper, writeTextFile
, vscodeExtensions ? [] }:
/*
@ -46,44 +46,15 @@ let
wrappedPkgVersion = lib.getVersion vscode;
wrappedPkgName = lib.removeSuffix "-${wrappedPkgVersion}" vscode.name;
toExtensionJsonEntry = drv: rec {
identifier = {
id = "${drv.vscodeExtPublisher}.${drv.vscodeExtName}";
uuid = "";
};
version = drv.version;
location = {
"$mid" = 1;
fsPath = drv.outPath + "/share/vscode/extensions/${drv.vscodeExtUniqueId}";
path = location.fsPath;
scheme = "file";
};
metadata = {
id = identifier.uuid;
publisherId = "";
publisherDisplayName = drv.vscodeExtPublisher;
targetPlatform = "undefined";
isApplicationScoped = false;
updated = false;
isPreReleaseVersion = false;
installedTimestamp = 0;
preRelease = false;
};
extensionJsonFile = writeTextFile {
name = "vscode-extensions-json";
destination = "/share/vscode/extensions/extensions.json";
text = vscode-utils.toExtensionJson vscodeExtensions;
};
extensionJson = builtins.toJSON (map toExtensionJsonEntry vscodeExtensions);
extensionJsonFile = writeText "extensions.json" extensionJson;
extensionJsonOutput = runCommand "vscode-extensions-json" {} ''
mkdir -p $out/share/vscode/extensions
cp ${extensionJsonFile} $out/share/vscode/extensions/extensions.json
'';
combinedExtensionsDrv = buildEnv {
name = "vscode-extensions";
paths = vscodeExtensions ++ [ extensionJsonOutput ];
paths = vscodeExtensions ++ [ extensionJsonFile ];
};
extensionsFlag = ''
@ -91,8 +62,6 @@ let
'';
in
# When no extensions are requested, we simply redirect to the original
# non-wrapped vscode executable.
runCommand "${wrappedPkgName}-with-extensions-${wrappedPkgVersion}" {
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ vscode ];