vscode: fix extension path for antigravity

Standardize the extension installation path to `/share/vscode/extensions`
regardless of the package name.

Previously, setting the package name to 'antigravity' would change the
internal path to `/share/antigravity`, which caused a mismatch because
most upstream Nixpkgs extensions are hardcoded to install into
`/share/vscode/extensions`. This resulted in an empty or incomplete
extensions directory in the nix store.

Also added 'antigravity' to the list of packages requiring an
immutable extensions.json file.

Signed-off-by: unlsycn <unlsycn@unlsycn.com>
This commit is contained in:
unlsycn 2026-01-31 12:51:23 +08:00 committed by Robert Helgesson
parent 47d542afdd
commit b593765639

View file

@ -27,7 +27,6 @@ let
"${cfg.package}/lib/antigravity" "${cfg.package}/lib/antigravity"
else else
"${cfg.package}/lib/vscode"; "${cfg.package}/lib/vscode";
sharePrefix = if vscodePname == "antigravity" then "/share/antigravity" else "/share/vscode";
productInfoPath = productInfoPath =
if if
@ -111,7 +110,7 @@ let
pkgs.writeTextFile { pkgs.writeTextFile {
inherit text; inherit text;
name = "extensions-json-${name}"; name = "extensions-json-${name}";
destination = "${sharePrefix}/extensions/extensions.json"; destination = "/share/vscode/extensions/extensions.json";
}; };
mergedUserSettings = mergedUserSettings =
@ -590,7 +589,7 @@ in
lib.mapAttrs' ( lib.mapAttrs' (
n: v: n: v:
lib.nameValuePair "${userDir}/profiles/${n}/extensions.json" { lib.nameValuePair "${userDir}/profiles/${n}/extensions.json" {
source = "${extensionJsonFile n (extensionJson v.extensions)}${sharePrefix}/extensions/extensions.json"; source = "${extensionJsonFile n (extensionJson v.extensions)}/share/vscode/extensions/extensions.json";
} }
) allProfilesExceptDefault ) allProfilesExceptDefault
)) ))
@ -598,7 +597,7 @@ in
(mkIf (cfg.profiles != { }) ( (mkIf (cfg.profiles != { }) (
let let
# Adapted from https://discourse.nixos.org/t/vscode-extensions-setup/1801/2 # Adapted from https://discourse.nixos.org/t/vscode-extensions-setup/1801/2
subDir = "${sharePrefix}/extensions"; subDir = "share/vscode/extensions";
toPaths = toPaths =
ext: ext:
map (k: { "${extensionPath}/${k}".source = "${ext}/${subDir}/${k}"; }) ( map (k: { "${extensionPath}/${k}".source = "${ext}/${subDir}/${k}"; }) (
@ -654,6 +653,7 @@ in
|| builtins.elem vscodePname [ || builtins.elem vscodePname [
"cursor" "cursor"
"windsurf" "windsurf"
"antigravity"
] ]
) )
&& defaultProfile != { } && defaultProfile != { }