blob: 087278a6d4d0790c32898462b2209f366cb29421 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
{
config,
lib,
pkgs,
...
}:
let
cfg = config.programs.vscode;
jsonFormat = pkgs.formats.json { };
in
{
options.programs.vscode = {
enable = lib.mkEnableOption "VSCode editor";
defaultEditor = lib.mkEnableOption "" // {
description = ''
When enabled, configures VSCode to be the default editor
using the EDITOR environment variable.
'';
};
package = lib.mkPackageOption pkgs "vscode" {
extraDescription = "The final package will be customized with extensions from {option}`programs.vscode.extensions`";
};
extensions = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
example = lib.literalExpression ''
with pkgs.vscode-extensions; [
bbenoist.nix
golang.go
twxs.cmake
]
'';
description = "List of extensions to install.";
};
enterprisePolicies = lib.mkOption {
type = jsonFormat.type;
default = { };
example = lib.literalExpression ''
{
"UpdateMode" = "none";
"TelemetryLevel" = "off";
}
'';
description = ''
System-wide policies for VSCode in `/etc/vscode/policy.json`.
See <https://code.visualstudio.com/docs/setup/enterprise#_centrally-manage-vs-code-settings> for more information.
'';
};
finalPackage = lib.mkOption {
type = lib.types.package;
visible = false;
readOnly = true;
description = "Resulting customized VSCode package.";
};
};
config = lib.mkIf cfg.enable {
environment = {
systemPackages = [
cfg.finalPackage
];
sessionVariables.EDITOR = lib.mkIf cfg.defaultEditor (
lib.mkOverride 900 cfg.finalPackage.meta.mainProgram
);
etc."vscode/policy.json" = lib.mkIf (cfg.enterprisePolicies != { }) {
source = jsonFormat.generate "vscode-policy.json" cfg.enterprisePolicies;
};
};
programs.vscode.finalPackage = pkgs.vscode-with-extensions.override {
vscode = cfg.package;
vscodeExtensions = cfg.extensions;
};
};
meta.maintainers = with lib.maintainers; [ ethancedwards8 ];
}
|