mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
vscode: add options to disable update checks
Update notification popups are annoying when vscode/vscodium is managed by Home Manager. However, as these settings also require the configuration to be managed via `userSettings`, they are disabled by default.
This commit is contained in:
parent
32fe7d2ebb
commit
d3f21617ac
4 changed files with 69 additions and 8 deletions
|
@ -34,6 +34,11 @@ let
|
||||||
# TODO: On Darwin where are the extensions?
|
# TODO: On Darwin where are the extensions?
|
||||||
extensionPath = ".${extensionDir}/extensions";
|
extensionPath = ".${extensionDir}/extensions";
|
||||||
|
|
||||||
|
mergedUserSettings = cfg.userSettings
|
||||||
|
// optionalAttrs (!cfg.enableUpdateCheck) { "update.mode" = "none"; }
|
||||||
|
// optionalAttrs (!cfg.enableExtensionUpdateCheck) {
|
||||||
|
"extensions.autoCheckUpdates" = false;
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
(mkChangedOptionModule [ "programs" "vscode" "immutableExtensionsDir" ] [
|
(mkChangedOptionModule [ "programs" "vscode" "immutableExtensionsDir" ] [
|
||||||
|
@ -56,12 +61,28 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enableUpdateCheck = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether to enable update checks/notifications.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
enableExtensionUpdateCheck = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether to enable update notifications for extensions.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
userSettings = mkOption {
|
userSettings = mkOption {
|
||||||
type = jsonFormat.type;
|
type = jsonFormat.type;
|
||||||
default = { };
|
default = { };
|
||||||
example = literalExpression ''
|
example = literalExpression ''
|
||||||
{
|
{
|
||||||
"update.channel" = "none";
|
"files.autoSave" = "off"
|
||||||
"[nix]"."editor.tabSize" = 2;
|
"[nix]"."editor.tabSize" = 2;
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
@ -164,9 +185,9 @@ in {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
home.file = mkMerge [
|
home.file = mkMerge [
|
||||||
(mkIf (cfg.userSettings != { }) {
|
(mkIf (mergedUserSettings != { }) {
|
||||||
"${configFilePath}".source =
|
"${configFilePath}".source =
|
||||||
jsonFormat.generate "vscode-user-settings" cfg.userSettings;
|
jsonFormat.generate "vscode-user-settings" mergedUserSettings;
|
||||||
})
|
})
|
||||||
(mkIf (cfg.userTasks != { }) {
|
(mkIf (cfg.userTasks != { }) {
|
||||||
"${tasksFilePath}".source =
|
"${tasksFilePath}".source =
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
{ vscode-keybindings = ./keybindings.nix; }
|
{
|
||||||
|
vscode-keybindings = ./keybindings.nix;
|
||||||
|
vscode-update-checks = ./update-checks.nix;
|
||||||
|
}
|
||||||
|
|
|
@ -27,12 +27,17 @@ let
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
targetPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
keybindingsPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
"Library/Application Support/Code/User/keybindings.json"
|
"Library/Application Support/Code/User/keybindings.json"
|
||||||
else
|
else
|
||||||
".config/Code/User/keybindings.json";
|
".config/Code/User/keybindings.json";
|
||||||
|
|
||||||
expectedJson = pkgs.writeText "expected.json" ''
|
settingsPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"Library/Application Support/Code/User/settings.json"
|
||||||
|
else
|
||||||
|
".config/Code/User/settings.json";
|
||||||
|
|
||||||
|
expectedKeybindings = pkgs.writeText "expected.json" ''
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"command": "editor.action.clipboardCopyAction",
|
"command": "editor.action.clipboardCopyAction",
|
||||||
|
@ -58,6 +63,7 @@ let
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in {
|
in {
|
||||||
config = {
|
config = {
|
||||||
programs.vscode = {
|
programs.vscode = {
|
||||||
|
@ -67,8 +73,10 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileExists "home-files/${targetPath}"
|
assertFileExists "home-files/${keybindingsPath}"
|
||||||
assertFileContent "home-files/${targetPath}" "${expectedJson}"
|
assertFileContent "home-files/${keybindingsPath}" "${expectedKeybindings}"
|
||||||
|
|
||||||
|
assertPathNotExists "home-files/${settingsPath}"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
29
tests/modules/programs/vscode/update-checks.nix
Normal file
29
tests/modules/programs/vscode/update-checks.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
settingsPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
"Library/Application Support/Code/User/settings.json"
|
||||||
|
else
|
||||||
|
".config/Code/User/settings.json";
|
||||||
|
|
||||||
|
expectedSettings = pkgs.writeText "settings-expected.json" ''
|
||||||
|
{
|
||||||
|
"extensions.autoCheckUpdates": false,
|
||||||
|
"update.mode": "none"
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
in {
|
||||||
|
programs.vscode = {
|
||||||
|
enable = true;
|
||||||
|
package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
|
||||||
|
enableUpdateCheck = false;
|
||||||
|
enableExtensionUpdateCheck = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists "home-files/${settingsPath}"
|
||||||
|
assertFileContent "home-files/${settingsPath}" "${expectedSettings}"
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue