1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

vscode: fix keybindings existence check (#2707)

... and flip immutableExtensionsDir to mutableExtensionsDir
This commit is contained in:
Naïm Favier 2022-02-07 18:40:59 +01:00 committed by GitHub
parent 63dccc4e60
commit 1ca6293c8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,6 +34,14 @@ let
extensionPath = ".${extensionDir}/extensions"; extensionPath = ".${extensionDir}/extensions";
in { in {
imports = [
(mkChangedOptionModule [ "programs" "vscode" "immutableExtensionsDir" ] [
"programs"
"vscode"
"mutableExtensionsDir"
] (config: !config.programs.vscode.immutableExtensionsDir))
];
options = { options = {
programs.vscode = { programs.vscode = {
enable = mkEnableOption "Visual Studio Code"; enable = mkEnableOption "Visual Studio Code";
@ -118,10 +126,10 @@ in {
''; '';
}; };
immutableExtensionsDir = mkOption { mutableExtensionsDir = mkOption {
type = types.bool; type = types.bool;
default = false; default = true;
example = true; example = false;
description = '' description = ''
Whether extensions can be installed or updated manually Whether extensions can be installed or updated manually
or by Visual Studio Code. or by Visual Studio Code.
@ -138,7 +146,7 @@ in {
"${configFilePath}".source = "${configFilePath}".source =
jsonFormat.generate "vscode-user-settings" cfg.userSettings; jsonFormat.generate "vscode-user-settings" cfg.userSettings;
}) })
(mkIf (cfg.keybindings != { }) (mkIf (cfg.keybindings != [ ])
(let dropNullFields = filterAttrs (_: v: v != null); (let dropNullFields = filterAttrs (_: v: v != null);
in { in {
"${keybindingsFilePath}".source = "${keybindingsFilePath}".source =
@ -158,10 +166,11 @@ in {
"${extensionPath}/${k}".source = "${extensionsFolder}/${k}"; "${extensionPath}/${k}".source = "${extensionsFolder}/${k}";
}; };
extensions = builtins.attrNames (builtins.readDir extensionsFolder); extensions = builtins.attrNames (builtins.readDir extensionsFolder);
in if cfg.immutableExtensionsDir then { in if cfg.mutableExtensionsDir then
mkMerge (map addSymlinkToExtension extensions)
else {
"${extensionPath}".source = extensionsFolder; "${extensionPath}".source = extensionsFolder;
} else }))
mkMerge (map addSymlinkToExtension extensions)))
]; ];
}; };
} }