2020-06-02 18:00:15 +00:00
|
|
|
{ stdenv, lib, buildEnv, writeShellScriptBin, fetchurl, vscode, unzip, jq }:
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
|
|
|
buildVscodeExtension = a@{
|
|
|
|
name,
|
|
|
|
src,
|
|
|
|
# Same as "Unique Identifier" on the extension's web page.
|
|
|
|
# For the moment, only serve as unique extension dir.
|
|
|
|
vscodeExtUniqueId,
|
2021-10-06 13:57:05 +00:00
|
|
|
configurePhase ? ''
|
|
|
|
runHook preConfigure
|
|
|
|
runHook postConfigure
|
|
|
|
'',
|
|
|
|
buildPhase ?''
|
|
|
|
runHook preBuild
|
|
|
|
runHook postBuild
|
|
|
|
'',
|
2020-04-24 23:36:52 +00:00
|
|
|
dontPatchELF ? true,
|
|
|
|
dontStrip ? true,
|
2022-01-19 23:45:15 +00:00
|
|
|
nativeBuildInputs ? [],
|
2020-04-24 23:36:52 +00:00
|
|
|
...
|
|
|
|
}:
|
2020-06-18 07:06:33 +00:00
|
|
|
stdenv.mkDerivation ((removeAttrs a [ "vscodeExtUniqueId" ]) // {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
name = "vscode-extension-${name}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
inherit vscodeExtUniqueId;
|
|
|
|
inherit configurePhase buildPhase dontPatchELF dontStrip;
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
nativeBuildInputs = [ unzip ] ++ nativeBuildInputs;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
2020-06-02 18:00:15 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p "$out/$installPrefix"
|
|
|
|
find . -mindepth 1 -maxdepth 1 | xargs -d'\n' mv -t "$out/$installPrefix/"
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
fetchVsixFromVscodeMarketplace = mktplcExtRef:
|
2020-06-02 18:00:15 +00:00
|
|
|
fetchurl((import ./mktplcExtRefToFetchArgs.nix mktplcExtRef));
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildVscodeMarketplaceExtension = 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 fetchVsixFromVscodeMarketplace mktplcRef;
|
|
|
|
vscodeExtUniqueId = "${mktplcRef.publisher}.${mktplcRef.name}";
|
|
|
|
});
|
|
|
|
|
|
|
|
mktplcRefAttrList = [
|
|
|
|
"name"
|
|
|
|
"publisher"
|
|
|
|
"version"
|
|
|
|
"sha256"
|
|
|
|
];
|
|
|
|
|
|
|
|
mktplcExtRefToExtDrv = ext:
|
|
|
|
buildVscodeMarketplaceExtension ((removeAttrs ext mktplcRefAttrList) // {
|
|
|
|
mktplcRef = ext;
|
|
|
|
});
|
|
|
|
|
|
|
|
extensionFromVscodeMarketplace = mktplcExtRefToExtDrv;
|
|
|
|
extensionsFromVscodeMarketplace = mktplcExtRefList:
|
|
|
|
builtins.map extensionFromVscodeMarketplace mktplcExtRefList;
|
|
|
|
|
2020-06-02 18:00:15 +00:00
|
|
|
vscodeWithConfiguration = import ./vscodeWithConfiguration.nix {
|
|
|
|
inherit lib extensionsFromVscodeMarketplace writeShellScriptBin;
|
|
|
|
vscodeDefault = vscode;
|
|
|
|
};
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
|
2020-06-02 18:00:15 +00:00
|
|
|
vscodeExts2nix = import ./vscodeExts2nix.nix {
|
|
|
|
inherit lib writeShellScriptBin;
|
|
|
|
vscodeDefault = vscode;
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-06-02 18:00:15 +00:00
|
|
|
vscodeEnv = import ./vscodeEnv.nix {
|
|
|
|
inherit lib buildEnv writeShellScriptBin extensionsFromVscodeMarketplace jq;
|
|
|
|
vscodeDefault = vscode;
|
|
|
|
};
|
2020-06-18 07:06:33 +00:00
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
{
|
|
|
|
inherit fetchVsixFromVscodeMarketplace buildVscodeExtension
|
|
|
|
buildVscodeMarketplaceExtension extensionFromVscodeMarketplace
|
2020-06-02 18:00:15 +00:00
|
|
|
extensionsFromVscodeMarketplace
|
|
|
|
vscodeWithConfiguration vscodeExts2nix vscodeEnv;
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|