12 buildVscodeExtension =
14 pname ? null, # Only optional for backward compatibility.
16 # Same as "Unique Identifier" on the extension's web page.
17 # For the moment, only serve as unique extension dir.
31 nativeBuildInputs ? [ ],
40 // (lib.optionalAttrs (pname != null) {
41 pname = "vscode-extension-${pname}";
45 passthru = passthru // {
46 inherit vscodeExtPublisher vscodeExtName vscodeExtUniqueId;
56 # Some .vsix files contain other directories (e.g., `package`) that we don't use.
57 # If other directories are present but `sourceRoot` is unset, the unpacker phase fails.
58 sourceRoot = "extension";
60 installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}";
62 nativeBuildInputs = [ unzip ] ++ nativeBuildInputs;
68 mkdir -p "$out/$installPrefix"
69 find . -mindepth 1 -maxdepth 1 | xargs -d'\n' mv -t "$out/$installPrefix/"
76 fetchVsixFromVscodeMarketplace =
77 mktplcExtRef: fetchurl (import ./mktplcExtRefToFetchArgs.nix mktplcExtRef);
79 buildVscodeMarketplaceExtension =
89 buildVscodeExtension (
95 pname = "${mktplcRef.publisher}-${mktplcRef.name}";
96 version = mktplcRef.version;
97 src = if (vsix != null) then vsix else fetchVsixFromVscodeMarketplace mktplcRef;
98 vscodeExtPublisher = mktplcRef.publisher;
99 vscodeExtName = mktplcRef.name;
100 vscodeExtUniqueId = "${mktplcRef.publisher}.${mktplcRef.name}";
104 mktplcRefAttrList = [
113 mktplcExtRefToExtDrv =
115 buildVscodeMarketplaceExtension (
116 removeAttrs ext mktplcRefAttrList
118 mktplcRef = builtins.intersectAttrs (lib.genAttrs mktplcRefAttrList (_: null)) ext;
122 extensionFromVscodeMarketplace = mktplcExtRefToExtDrv;
123 extensionsFromVscodeMarketplace =
124 mktplcExtRefList: builtins.map extensionFromVscodeMarketplace mktplcExtRefList;
126 vscodeWithConfiguration = import ./vscodeWithConfiguration.nix {
127 inherit lib extensionsFromVscodeMarketplace writeShellScriptBin;
128 vscodeDefault = vscode;
131 vscodeExts2nix = import ./vscodeExts2nix.nix {
132 inherit lib writeShellScriptBin;
133 vscodeDefault = vscode;
136 vscodeEnv = import ./vscodeEnv.nix {
141 extensionsFromVscodeMarketplace
144 vscodeDefault = vscode;
147 toExtensionJsonEntry = ext: rec {
149 id = ext.vscodeExtUniqueId;
153 version = ext.version;
155 relativeLocation = ext.vscodeExtUniqueId;
159 fsPath = ext.outPath + "/share/vscode/extensions/${ext.vscodeExtUniqueId}";
160 path = location.fsPath;
167 publisherDisplayName = ext.vscodeExtPublisher;
168 targetPlatform = "undefined";
169 isApplicationScoped = false;
171 isPreReleaseVersion = false;
172 installedTimestamp = 0;
177 toExtensionJson = extensions: builtins.toJSON (map toExtensionJsonEntry extensions);
181 fetchVsixFromVscodeMarketplace
183 buildVscodeMarketplaceExtension
184 extensionFromVscodeMarketplace
185 extensionsFromVscodeMarketplace
186 vscodeWithConfiguration