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