1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-11 11:17:03 +00:00
home-manager/tests/modules/programs/vscode/tasks.nix

58 lines
1.3 KiB
Nix
Raw Normal View History

{ pkgs, lib, ... }:
2022-10-29 10:47:06 +09:00
let
tasksFilePath = name:
if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}tasks.json"
else
".config/Code/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}tasks.json";
2022-10-29 10:47:06 +09:00
tasks = {
version = "2.0.0";
tasks = [{
type = "shell";
label = "Hello task";
command = "hello";
}];
};
expectedTasks = pkgs.writeText "tasks-expected.json" ''
{
"tasks": [
{
"command": "hello",
"label": "Hello task",
"type": "shell"
}
],
"version": "2.0.0"
}
'';
in {
programs.vscode = {
enable = true;
package = pkgs.writeScriptBin "vscode" "" // {
pname = "vscode";
version = "1.75.0";
};
profiles = {
default.userTasks = tasks;
test.userTasks = tasks;
};
2022-10-29 10:47:06 +09:00
};
nmt.script = ''
assertFileExists "home-files/${tasksFilePath "default"}"
assertFileContent "home-files/${tasksFilePath "default"}" "${expectedTasks}"
assertFileExists "home-files/${tasksFilePath "test"}"
assertFileContent "home-files/${tasksFilePath "test"}" "${expectedTasks}"
2022-10-29 10:47:06 +09:00
'';
}