Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ publisher, name, version, arch ? "", sha256 ? "" }:
let
url =
if arch == ""
then "https://open-vsx.org/api/${publisher}/${name}/${version}/file/${publisher}.${name}-${version}.vsix"
else "https://open-vsx.org/api/${publisher}/${name}/${arch}/${version}/file/${publisher}.${name}-${version}.vsix";
in
{
inherit url;
sha256 = sha256;
name = "${publisher}-${name}.zip";
}
36 changes: 32 additions & 4 deletions pkgs/applications/editors/vscode/extensions/vscode-utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ let
fetchVsixFromVscodeMarketplace = mktplcExtRef:
fetchurl (import ./mktplcExtRefToFetchArgs.nix mktplcExtRef);

fetchVsixFromOpenVsx = mktplcExtRef:
fetchurl (import ./openvsxExtRefToFetchArgs.nix mktplcExtRef);

buildVscodeMarketplaceExtension = a@{
name ? "",
src ? null,
Expand All @@ -60,6 +63,21 @@ let
vscodeExtUniqueId = "${mktplcRef.publisher}.${mktplcRef.name}";
});

buildOpenVsxExtension = a@{
name ? "",
src ? null,
vsix ? null,
mktplcRef,
...
}: assert "" == name; assert null == src;
buildVscodeExtension ((removeAttrs a [ "mktplcRef" "vsix" ]) // {
name = "${mktplcRef.publisher}-${mktplcRef.name}-${mktplcRef.version}";
src = if (vsix != null)
then vsix
else fetchVsixFromOpenVsx mktplcRef;
vscodeExtUniqueId = "${mktplcRef.publisher}.${mktplcRef.name}";
});

mktplcRefAttrList = [
"name"
"publisher"
Expand All @@ -73,16 +91,24 @@ let
mktplcRef = builtins.intersectAttrs (lib.genAttrs mktplcRefAttrList (_: null)) ext;
});

openvsxExtRefToExtDrv = ext:
buildOpenVsxExtension (removeAttrs ext mktplcRefAttrList // {
mktplcRef = builtins.intersectAttrs (lib.genAttrs mktplcRefAttrList (_: null)) ext;
});

extensionFromVscodeMarketplace = mktplcExtRefToExtDrv;
extensionsFromVscodeMarketplace = mktplcExtRefList:
builtins.map extensionFromVscodeMarketplace mktplcExtRefList;

extensionFromOpenVsx = openvsxExtRefToExtDrv;
extensionsFromOpenVsx = mktplcExtRefList:
builtins.map extensionFromOpenVsx mktplcExtRefList;

vscodeWithConfiguration = import ./vscodeWithConfiguration.nix {
inherit lib extensionsFromVscodeMarketplace writeShellScriptBin;
vscodeDefault = vscode;
};


vscodeExts2nix = import ./vscodeExts2nix.nix {
inherit lib writeShellScriptBin;
vscodeDefault = vscode;
Expand All @@ -95,7 +121,9 @@ let
in
{
inherit fetchVsixFromVscodeMarketplace buildVscodeExtension
buildVscodeMarketplaceExtension extensionFromVscodeMarketplace
extensionsFromVscodeMarketplace
vscodeWithConfiguration vscodeExts2nix vscodeEnv;
buildVscodeMarketplaceExtension extensionFromVscodeMarketplace
extensionsFromVscodeMarketplace
vscodeWithConfiguration vscodeExts2nix vscodeEnv;
inherit fetchVsixFromOpenVsx buildOpenVsxExtension
openvsxExtRefToExtDrv extensionFromOpenVsx;
}