Files
home-manager/tests/modules/programs/vscode/path-literal.nix
Austin Horstman f96f717a47 vscode: support path literals in userSettings
programs.vscode.profiles.<name>.userSettings accepts either JSON settings or a path to a settings.json file. The update-check defaults were merged into userSettings before deciding whether to generate JSON or link a source file, so path values failed when Nix tried to apply // to them.

Skip those merges for path-like values and use the shared isPathLike helper for VS Code's source-or-generated JSON options so Nix paths, store path strings, and derivation outputs are handled consistently.

Fixes #7726
2026-06-10 13:10:31 -05:00

34 lines
625 B
Nix

package:
{
pkgs,
...
}:
let
settingsPath =
if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/settings.json"
else
".config/Code/User/settings.json";
in
{
programs.vscode = {
enable = true;
inherit package;
profiles = {
default = {
userSettings = ./path-literal-settings.json;
enableUpdateCheck = false;
enableExtensionUpdateCheck = false;
};
};
};
nmt.script = ''
assertFileExists "home-files/${settingsPath}"
assertFileContent "home-files/${settingsPath}" "${./path-literal-settings.json}"
'';
}