-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvscode.nix
50 lines (48 loc) · 1.55 KB
/
vscode.nix
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
topLevel@{ flake-parts-lib, lib, ... }: {
imports = [
./devcontainer.nix
topLevel.inputs.flake-parts.flakeModules.flakeModules
];
flake.flakeModules.vscode = flakeModule:{
imports = [
topLevel.config.flake.flakeModules.devcontainer
];
options.perSystem = flake-parts-lib.mkPerSystemOption {
config.ml-ops.devcontainer.nixago.requests = {
options = {
".vscode/extensions.json".data.recommendations = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
};
".vscode/settings.json" = {
data = lib.mkOption {
type = lib.types.attrsOf lib.types.anything;
default = { };
};
hook.mode = lib.mkOption {
type = lib.types.str;
default = "copy";
};
};
};
config =
let
settingsJson = ".vscode/settings.json";
mkRecursiveDefault = value:
if builtins.isList value
then builtins.map mkRecursiveDefault value
else if builtins.isAttrs value
then lib.attrsets.mapAttrs (name: mkRecursiveDefault) value
else lib.mkDefault value;
in
{
"${settingsJson}".data =
if builtins.pathExists "${flakeModule.self}/${settingsJson}"
then mkRecursiveDefault (builtins.fromJSON (builtins.readFile "${flakeModule.self}/${settingsJson}"))
else { }
;
};
};
};
};
}