1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

vscode: also test unknown package if IFD is enabled

This commit is contained in:
andre4ik3 2025-10-04 04:00:33 +00:00 committed by Robert Helgesson
parent 03f83f513d
commit 5f06ceafc6
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED
6 changed files with 125 additions and 54 deletions

View file

@ -1,7 +1,37 @@
{ { pkgs, lib, ... }:
vscode-keybindings = ./keybindings.nix;
vscode-tasks = ./tasks.nix; let
vscode-mcp = ./mcp.nix; knownPackage = pkgs.writeScriptBin "vscode" "" // {
vscode-update-checks = ./update-checks.nix; pname = "vscode";
vscode-snippets = ./snippets.nix; version = "1.75.0";
} };
unknownPackage = pkgs.writeTextFile rec {
name = "${derivationArgs.pname}-${derivationArgs.version}";
derivationArgs = {
pname = "test-vscode-unknown";
version = "0.1.0";
};
text = builtins.toJSON {
dataFolderName = ".test-vscode-unknown";
nameShort = passthru.longName;
};
destination = "/lib/vscode/resources/app/product.json";
passthru.longName = "Test VSCode Fork";
};
tests = {
keybindings = import ./keybindings.nix;
tasks = import ./tasks.nix;
mcp = import ./mcp.nix;
update-checks = import ./update-checks.nix;
snippets = import ./snippets.nix;
};
knownTests = lib.mapAttrs' (k: v: lib.nameValuePair "vscode-${k}-known" (v knownPackage)) tests;
unknownTests = lib.mapAttrs' (
k: v: lib.nameValuePair "vscode-${k}-unknown" (v unknownPackage)
) tests;
in
knownTests // unknownTests

View file

@ -1,7 +1,17 @@
# Test that keybindings.json is created correctly. # Test that keybindings.json is created correctly.
{ pkgs, lib, ... }: package:
{
config,
pkgs,
lib,
...
}:
let let
cfg = config.programs.vscode;
willUseIfd = package.pname != "vscode";
bindings = [ bindings = [
{ {
key = "ctrl+c"; key = "ctrl+c";
@ -30,20 +40,24 @@ let
keybindingsPath = keybindingsPath =
name: name:
if pkgs.stdenv.hostPlatform.isDarwin then if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/${ "Library/Application Support/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/" lib.optionalString (name != "default") "profiles/${name}/"
}keybindings.json" }keybindings.json"
else else
".config/Code/User/${lib.optionalString (name != "default") "profiles/${name}/"}keybindings.json"; ".config/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}keybindings.json";
settingsPath = settingsPath =
name: name:
if pkgs.stdenv.hostPlatform.isDarwin then if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/${ "Library/Application Support/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/" lib.optionalString (name != "default") "profiles/${name}/"
}settings.json" }settings.json"
else else
".config/Code/User/${lib.optionalString (name != "default") "profiles/${name}/"}settings.json"; ".config/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}settings.json";
content = '' content = ''
[ [
@ -109,9 +123,9 @@ let
''; '';
expectedCustomKeybindings = pkgs.writeText "custom-expected.json" content; expectedCustomKeybindings = pkgs.writeText "custom-expected.json" content;
in in
{
lib.mkIf (willUseIfd -> config.test.enableLegacyIfd) {
programs.vscode = { programs.vscode = {
enable = true; enable = true;
profiles = { profiles = {
@ -119,10 +133,7 @@ in
test.keybindings = bindings; test.keybindings = bindings;
custom.keybindings = customBindingsPath; custom.keybindings = customBindingsPath;
}; };
package = pkgs.writeScriptBin "vscode" "" // { inherit package;
pname = "vscode";
version = "1.75.0";
};
}; };
nmt.script = '' nmt.script = ''

View file

@ -1,15 +1,26 @@
{ pkgs, lib, ... }: package:
{
config,
pkgs,
lib,
...
}:
let let
cfg = config.programs.vscode;
willUseIfd = package.pname != "vscode";
mcpFilePath = mcpFilePath =
name: name:
if pkgs.stdenv.hostPlatform.isDarwin then if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/${ "Library/Application Support/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/" lib.optionalString (name != "default") "profiles/${name}/"
}mcp.json" }mcp.json"
else else
".config/Code/User/${lib.optionalString (name != "default") "profiles/${name}/"}mcp.json"; ".config/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}mcp.json";
content = '' content = ''
{ {
@ -42,15 +53,12 @@ let
''; '';
expectedCustomMcp = pkgs.writeText "custom-expected.json" content; expectedCustomMcp = pkgs.writeText "custom-expected.json" content;
in in
{
lib.mkIf (willUseIfd -> config.test.enableLegacyIfd) {
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.writeScriptBin "vscode" "" // { inherit package;
pname = "vscode";
version = "1.75.0";
};
profiles = { profiles = {
default.userMcp = mcp; default.userMcp = mcp;
test.userMcp = mcp; test.userMcp = mcp;

View file

@ -1,15 +1,26 @@
{ pkgs, lib, ... }: package:
{
config,
pkgs,
lib,
...
}:
let let
cfg = config.programs.vscode;
willUseIfd = package.pname != "vscode";
snippetsDir = snippetsDir =
name: name:
if pkgs.stdenv.hostPlatform.isDarwin then if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/${ "Library/Application Support/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/" lib.optionalString (name != "default") "profiles/${name}/"
}/snippets" }/snippets"
else else
".config/Code/User/${lib.optionalString (name != "default") "profiles/${name}/"}snippets"; ".config/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}snippets";
globalSnippetsPath = name: "${snippetsDir name}/global.code-snippets"; globalSnippetsPath = name: "${snippetsDir name}/global.code-snippets";
@ -61,15 +72,12 @@ let
}; };
}; };
}; };
in in
{
lib.mkIf (willUseIfd -> config.test.enableLegacyIfd) {
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.writeScriptBin "vscode" "" // { inherit package;
pname = "vscode";
version = "1.75.0";
};
profiles = { profiles = {
default = snippets; default = snippets;
test = snippets; test = snippets;

View file

@ -1,15 +1,26 @@
{ pkgs, lib, ... }: package:
{
config,
pkgs,
lib,
...
}:
let let
cfg = config.programs.vscode;
willUseIfd = package.pname != "vscode";
tasksFilePath = tasksFilePath =
name: name:
if pkgs.stdenv.hostPlatform.isDarwin then if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/${ "Library/Application Support/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/" lib.optionalString (name != "default") "profiles/${name}/"
}tasks.json" }tasks.json"
else else
".config/Code/User/${lib.optionalString (name != "default") "profiles/${name}/"}tasks.json"; ".config/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}tasks.json";
content = '' content = ''
{ {
@ -57,15 +68,12 @@ let
''; '';
expectedCustomTasks = pkgs.writeText "custom-expected.json" content; expectedCustomTasks = pkgs.writeText "custom-expected.json" content;
in in
{
lib.mkIf (willUseIfd -> config.test.enableLegacyIfd) {
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.writeScriptBin "vscode" "" // { inherit package;
pname = "vscode";
version = "1.75.0";
};
profiles = { profiles = {
default.userTasks = tasks; default.userTasks = tasks;
test.userTasks = tasks; test.userTasks = tasks;

View file

@ -1,12 +1,21 @@
{ pkgs, ... }: package:
{
config,
pkgs,
lib,
...
}:
let let
cfg = config.programs.vscode;
willUseIfd = package.pname != "vscode";
settingsPath = settingsPath =
if pkgs.stdenv.hostPlatform.isDarwin then if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/settings.json" "Library/Application Support/${cfg.nameShort}/User/settings.json"
else else
".config/Code/User/settings.json"; ".config/${cfg.nameShort}/User/settings.json";
expectedSettings = pkgs.writeText "settings-expected.json" '' expectedSettings = pkgs.writeText "settings-expected.json" ''
{ {
@ -14,15 +23,12 @@ let
"update.mode": "none" "update.mode": "none"
} }
''; '';
in in
{
lib.mkIf (willUseIfd -> config.test.enableLegacyIfd) {
programs.vscode = { programs.vscode = {
enable = true; enable = true;
package = pkgs.writeScriptBin "vscode" "" // { inherit package;
pname = "vscode";
version = "1.75.0";
};
profiles.default = { profiles.default = {
enableUpdateCheck = false; enableUpdateCheck = false;
enableExtensionUpdateCheck = false; enableExtensionUpdateCheck = false;