vscode-utils: add unpackVsixSetupHook (#464215)

This commit is contained in:
Sandro
2025-12-12 23:51:52 +00:00
committed by GitHub
11 changed files with 34 additions and 41 deletions
@@ -13,6 +13,7 @@ vscode-utils.buildVscodeExtension (finalAttrs: {
src = gemini-cli.overrideAttrs (oldAttrs: {
pname = "gemini-cli-vscode-ide-companion-vsix";
name = "${finalAttrs.pname}-${finalAttrs.version}.vsix";
installPhase = ''
runHook preInstall
@@ -23,14 +24,6 @@ vscode-utils.buildVscodeExtension (finalAttrs: {
'';
});
unpackPhase = ''
runHook preUnpack
unzip $src
runHook postUnpack
'';
meta = {
description = "Enable Gemini CLI with direct access to your IDE workspace";
homepage = "https://github.com/google-gemini/gemini-cli";
@@ -2302,18 +2302,6 @@ let
};
};
influxdata.flux = buildVscodeMarketplaceExtension {
mktplcRef = {
publisher = "influxdata";
name = "flux";
version = "1.0.5";
hash = "sha256-KIKROyfkosBS1Resgl+s3VENVg4ibaeIgKjermXESoA=";
};
meta = {
license = lib.licenses.mit;
};
};
intellsmi.comment-translate = buildVscodeMarketplaceExtension {
mktplcRef = {
publisher = "intellsmi";
@@ -4913,7 +4901,7 @@ let
};
vsix = fetchurl {
name = "${mktplcRef.publisher}-${mktplcRef.name}.zip";
name = "${mktplcRef.publisher}-${mktplcRef.name}.vsix";
url = "https://github.com/valentjn/vscode-ltex/releases/download/${mktplcRef.version}/vscode-ltex-${mktplcRef.version}-offline-linux-x64.vsix";
sha256 = "1nlrijjwc35n1xgb5lgnr4yvlgfcxd0vdj93ip8lv2xi8x1ni5f6";
};
@@ -5545,6 +5533,7 @@ let
dendron.dendron-markdown-preview-enhanced = throw "dendron.dendron-markdown-preview-enhanced has been removed from the VSCode marketplace."; # Added 2025-08-21
equinusocio.vsc-material-theme = throw "'equinusocio.vsc-material-theme' has been removed due to security concerns. The extension contained potentially malicious code and was taken down."; # Added 2025-02-28
equinusocio.vsc-material-theme-icons = throw "'equinusocio.vsc-material-theme-icons' has been removed due to security concerns. The extension contained potentially malicious code and was taken down."; # Added 2025-02-28
influxdata.flux = throw "'influxdata.flux' has been removed due to being unmaintained upstream"; # Added 2025-12-09
jakebecker.elixir-ls = throw "jakebecker.elixir-ls is deprecated in favor of elixir-lsp.vscode-elixir-ls"; # Added 2024-05-29
jpoissonnier.vscode-styled-components = throw "jpoissonnier.vscode-styled-components is deprecated in favor of styled-components.vscode-styled-components"; # Added 2024-05-29
matklad.rust-analyzer = throw "matklad.rust-analyzer is deprecated in favor of rust-lang.rust-analyzer"; # Added 2024-05-29
@@ -11,7 +11,7 @@
let
vsix = stdenv.mkDerivation (finalAttrs: {
name = "gitlens-${finalAttrs.version}.zip";
name = "gitlens-${finalAttrs.version}.vsix";
pname = "gitlens-vsix";
version = "17.7.1";
@@ -60,14 +60,6 @@ vscode-utils.buildVscodeExtension (finalAttrs: {
src = vsix;
unpackPhase = ''
runHook preUnpack
unzip $src
runHook postUnpack
'';
passthru = {
vsix = finalAttrs.src;
updateScript = nix-update-script {
@@ -12,7 +12,7 @@ in
{
url = "https://${publisher}.gallery.vsassets.io/_apis/public/gallery/publisher/${publisher}/extension/${name}/${version}/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage${archurl}";
inherit sha256 hash;
# 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 = "${publisher}-${name}.zip";
# The `*.vsix` file is in the end a simple zip file. Force it using .vsix extension
# so that existing `unpackVsixSetupHook` hooks takes care of the unpacking.
name = "${publisher}-${name}.vsix";
}
@@ -10,8 +10,8 @@ vscode-utils.buildVscodeMarketplaceExtension {
mktplcRef = {
name = "tinymist";
publisher = "myriad-dreamin";
inherit (tinymist) version;
hash = "sha256-7BHkRM9HcD5VDMCcAh2GFvGz+OSb7l/Ki3+V3v/RYSo=";
version = "0.14.4";
hash = "sha256-Y8yIAIT0TrrM8ZQSZl4QnVG6uE0F+AwWFvmhLe0ZPto=";
};
nativeBuildInputs = [
@@ -10,7 +10,7 @@
let
vsix = stdenvNoCC.mkDerivation (finalAttrs: {
name = "roo-code-${finalAttrs.version}.zip";
name = "roo-code-${finalAttrs.version}.vsix";
pname = "roo-code-vsix";
version = "3.36.2";
@@ -32,6 +32,7 @@ let
vsix = buildNpmPackage {
inherit pname releaseTag;
name = "${pname}-${version}.vsix";
version = lib.trim (lib.readFile ./version.txt);
src = "${src}/editors/code";
npmDepsHash = "sha256-fV4Z3jj+v56A7wbIEYhVAPVuAMqMds5xSe3OetWAsbw=";
@@ -57,15 +58,14 @@ let
walk(del(.["$generated-start"]?) | del(.["$generated-end"]?))
' package.json | sponge package.json
mkdir -p $out
npx vsce package -o $out/${pname}.zip
npm exec --package=@vscode/vsce -- vsce package --out $out
'';
};
in
vscode-utils.buildVscodeExtension {
inherit version vsix pname;
src = "${vsix}/${pname}.zip";
src = vsix;
vscodeExtUniqueId = "${publisher}.${pname}";
vscodeExtPublisher = publisher;
vscodeExtName = pname;
@@ -0,0 +1,11 @@
unpackCmdHooks+=(_tryUnpackVsix)
_tryUnpackVsix() {
if ! [[ "$curSrc" =~ \.vsix$ ]]; then return 1; fi
# UTF-8 locale is needed for unzip on glibc to handle UTF-8 symbols:
# https://github.com/NixOS/nixpkgs/issues/176225#issuecomment-1146617263
# Otherwise unzip unpacks escaped file names as if '-U' options was in effect.
#
# Pick en_US.UTF-8 as most possible to be present on glibc, musl and darwin.
LANG=en_US.UTF-8 @unzip@ -qq "$curSrc"
}
@@ -12,7 +12,7 @@
let
vsix = stdenvNoCC.mkDerivation (finalAttrs: {
name = "vscode-icons-${finalAttrs.version}.zip";
name = "vscode-icons-${finalAttrs.version}.vsix";
pname = "vscode-icons-vsix";
version = "12.15.0";
@@ -6,10 +6,18 @@
fetchurl,
vscode,
unzip,
makeSetupHook,
writeScript,
jq,
vscode-extension-update-script,
}:
let
unpackVsixSetupHook = makeSetupHook {
name = "unpack-vsix-setup-hook";
substitutions = {
unzip = "${unzip}/bin/unzip";
};
} ./unpack-vsix-setup-hook.sh;
buildVscodeExtension = lib.extendMkDerivation {
constructDrv = stdenv.mkDerivation;
excludeDrvArgNames = [
@@ -63,7 +71,7 @@ let
# This cannot be removed, it is used by some extensions.
installPrefix = "share/vscode/extensions/${vscodeExtUniqueId}";
nativeBuildInputs = [ unzip ] ++ nativeBuildInputs;
nativeBuildInputs = [ unpackVsixSetupHook ] ++ nativeBuildInputs;
installPhase =
args.installPhase or ''