mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-12 20:11:06 +01:00
VS Code 1.102 separates MCP configuration from `settings.json` to a profile-specific `mcp.json`. VS Code automatically performs this separation if MCP configuration is detected inside `settings.json` which conflicts with the immutability of the settings.json that home-manager supplies.
71 lines
1.6 KiB
Nix
71 lines
1.6 KiB
Nix
{ pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
mcpFilePath =
|
|
name:
|
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
|
"Library/Application Support/Code/User/${
|
|
lib.optionalString (name != "default") "profiles/${name}/"
|
|
}mcp.json"
|
|
else
|
|
".config/Code/User/${lib.optionalString (name != "default") "profiles/${name}/"}mcp.json";
|
|
|
|
content = ''
|
|
{
|
|
"servers": {
|
|
"Github": {
|
|
"url": "https://api.githubcopilot.com/mcp/"
|
|
}
|
|
}
|
|
}
|
|
'';
|
|
|
|
mcp = {
|
|
servers = {
|
|
Github = {
|
|
url = "https://api.githubcopilot.com/mcp/";
|
|
};
|
|
};
|
|
};
|
|
|
|
customMcpPath = pkgs.writeText "custom.json" content;
|
|
|
|
expectedMcp = pkgs.writeText "mcp-expected.json" ''
|
|
{
|
|
"servers": {
|
|
"Github": {
|
|
"url": "https://api.githubcopilot.com/mcp/"
|
|
}
|
|
}
|
|
}
|
|
'';
|
|
|
|
expectedCustomMcp = pkgs.writeText "custom-expected.json" content;
|
|
|
|
in
|
|
{
|
|
programs.vscode = {
|
|
enable = true;
|
|
package = pkgs.writeScriptBin "vscode" "" // {
|
|
pname = "vscode";
|
|
version = "1.75.0";
|
|
};
|
|
profiles = {
|
|
default.userMcp = mcp;
|
|
test.userMcp = mcp;
|
|
custom.userMcp = customMcpPath;
|
|
};
|
|
};
|
|
|
|
nmt.script = ''
|
|
assertFileExists "home-files/${mcpFilePath "default"}"
|
|
assertFileContent "home-files/${mcpFilePath "default"}" "${expectedMcp}"
|
|
|
|
assertFileExists "home-files/${mcpFilePath "test"}"
|
|
assertFileContent "home-files/${mcpFilePath "test"}" "${expectedMcp}"
|
|
|
|
assertFileExists "home-files/${mcpFilePath "custom"}"
|
|
assertFileContent "home-files/${mcpFilePath "custom"}" "${expectedCustomMcp}"
|
|
'';
|
|
}
|