depot/third_party/home-manager/tests/modules/programs/vscode/keybindings.nix
Default email 72904c318c Project import generated by Copybara.
GitOrigin-RevId: 9bf1f40af124573a54fd208b1f539eb694ef31a6
2020-10-11 17:22:58 -07:00

53 lines
1.1 KiB
Nix

# Test that keybdinings.json is created correctly.
{ config, lib, pkgs, ... }:
with lib;
let
bindings = [
{
key = "ctrl+c";
command = "editor.action.clipboardCopyAction";
when = "textInputFocus && false";
}
{
key = "ctrl+c";
command = "deleteFile";
when = "";
}
{
key = "d";
command = "deleteFile";
when = "explorerViewletVisible";
}
];
targetPath = if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/Code/User/keybindings.json"
else
".config/Code/User/keybindings.json";
expectedJson = pkgs.writeText "expected.json" (builtins.toJSON bindings);
in {
config = {
programs.vscode = {
enable = true;
keybindings = bindings;
};
nixpkgs.overlays = [
(self: super: {
vscode = pkgs.runCommandLocal "vscode" { pname = "vscode"; } ''
mkdir -p $out/bin
touch $out/bin/code
chmod +x $out/bin/code;
'';
})
];
nmt.script = ''
assertFileExists "home-files/${targetPath}"
assertFileContent "home-files/${targetPath}" "${expectedJson}"
'';
};
}