2018-11-19 17:50:35 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.vscode;
|
|
|
|
|
2019-07-07 19:15:47 +02:00
|
|
|
configFilePath =
|
|
|
|
if pkgs.stdenv.hostPlatform.isDarwin then
|
|
|
|
"Library/Application Support/Code/User/settings.json"
|
|
|
|
else
|
|
|
|
"${config.xdg.configHome}/Code/User/settings.json";
|
|
|
|
|
2018-11-19 17:50:35 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
programs.vscode = {
|
|
|
|
enable = mkEnableOption "Visual Studio Code";
|
|
|
|
|
|
|
|
userSettings = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = {};
|
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
"update.channel" = "none";
|
|
|
|
"[nix]"."editor.tabSize" = 2;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
2019-07-07 19:15:47 +02:00
|
|
|
Configuration written to Visual Studio Code's
|
|
|
|
<filename>settings.json</filename>.
|
2018-11-19 17:50:35 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extensions = mkOption {
|
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [];
|
2019-05-31 21:37:28 +02:00
|
|
|
example = literalExample "[ pkgs.vscode-extensions.bbenoist.Nix ]";
|
2018-11-19 17:50:35 +01:00
|
|
|
description = ''
|
|
|
|
The extensions Visual Studio Code should be started with.
|
|
|
|
These will override but not delete manually installed ones.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = [
|
|
|
|
(pkgs.vscode-with-extensions.override {
|
|
|
|
vscodeExtensions = cfg.extensions;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2019-07-07 19:15:47 +02:00
|
|
|
home.file."${configFilePath}".text = builtins.toJSON cfg.userSettings;
|
2018-11-19 17:50:35 +01:00
|
|
|
};
|
|
|
|
}
|