mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
vscode: add extensions.json file in extensions dir (#3588)
* vscode: add extensions.json file in extensions dir This change generates an 'extensions.json` file the same way that nixpkgs' vscode-with-extensions does, and makes sure it is placed in the directory with the extensions. * vscode: remove leftover trace Co-authored-by: Naïm Favier <n@monade.li> * vscode: fix adding extensions.json with mutable extension dir Co-authored-by: Naïm Favier <n@monade.li> * vscode: let vscode regenerate the mutable extensions.json * Remove nixpkgs duplication; only apply on vscodes new enough to need it * Use lib.versionAtLeast Co-authored-by: Naïm Favier <n@monade.li> * Format vscode.nix --------- Co-authored-by: Naïm Favier <n@monade.li>
This commit is contained in:
parent
6d95d98b6b
commit
d7a5a28fc3
1 changed files with 25 additions and 2 deletions
|
@ -7,6 +7,7 @@ let
|
|||
cfg = config.programs.vscode;
|
||||
|
||||
vscodePname = cfg.package.pname;
|
||||
vscodeVersion = cfg.package.version;
|
||||
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
|
||||
|
@ -34,6 +35,13 @@ let
|
|||
# TODO: On Darwin where are the extensions?
|
||||
extensionPath = ".${extensionDir}/extensions";
|
||||
|
||||
extensionJson = pkgs.vscode-utils.toExtensionJson cfg.extensions;
|
||||
extensionJsonFile = pkgs.writeTextFile {
|
||||
name = "extensions-json";
|
||||
destination = "/share/vscode/extensions/extensions.json";
|
||||
text = extensionJson;
|
||||
};
|
||||
|
||||
mergedUserSettings = cfg.userSettings
|
||||
// optionalAttrs (!cfg.enableUpdateCheck) { "update.mode" = "none"; }
|
||||
// optionalAttrs (!cfg.enableExtensionUpdateCheck) {
|
||||
|
@ -55,6 +63,7 @@ in {
|
|||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.vscode;
|
||||
defaultText = literalExpression "pkgs.vscode";
|
||||
example = literalExpression "pkgs.vscodium";
|
||||
description = ''
|
||||
Version of Visual Studio Code to install.
|
||||
|
@ -211,12 +220,26 @@ in {
|
|||
else
|
||||
builtins.attrNames (builtins.readDir (ext + "/${subDir}")));
|
||||
in if cfg.mutableExtensionsDir then
|
||||
mkMerge (concatMap toPaths cfg.extensions)
|
||||
mkMerge (concatMap toPaths cfg.extensions
|
||||
++ lib.optional (lib.versionAtLeast vscodeVersion "1.74.0") [{
|
||||
# Whenever our immutable extensions.json changes, force VSCode to regenerate
|
||||
# extensions.json with both mutable and immutable extensions.
|
||||
"${extensionPath}/.extensions-immutable.json" = {
|
||||
text = extensionJson;
|
||||
onChange = ''
|
||||
$DRY_RUN_CMD rm $VERBOSE_ARG -f ${extensionPath}/{extensions.json,.init-default-profile-extensions}
|
||||
$VERBOSE_ECHO "Regenerating VSCode extensions.json"
|
||||
$DRY_RUN_CMD ${getExe cfg.package} --list-extensions > /dev/null
|
||||
'';
|
||||
};
|
||||
}])
|
||||
else {
|
||||
"${extensionPath}".source = let
|
||||
combinedExtensionsDrv = pkgs.buildEnv {
|
||||
name = "vscode-extensions";
|
||||
paths = cfg.extensions;
|
||||
paths = cfg.extensions
|
||||
++ lib.optional (lib.versionAtLeast vscodeVersion "1.74.0")
|
||||
[ extensionJsonFile ];
|
||||
};
|
||||
in "${combinedExtensionsDrv}/${subDir}";
|
||||
}))
|
||||
|
|
Loading…
Reference in a new issue