mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
vscode: Get paths from product.json
The VSCode packages contain a product.json which is used to determine the extension and config dirs. Instead of hardcoding the package name, this change parses this file (which may appear in one of two places) and uses that to generate the paths. This hopefully allows more VSCode derivatives to "just work" without home-manager updates.
This commit is contained in:
parent
038630363e
commit
6f7f29f672
6 changed files with 24 additions and 17 deletions
|
@ -11,19 +11,17 @@ let
|
||||||
|
|
||||||
jsonFormat = pkgs.formats.json { };
|
jsonFormat = pkgs.formats.json { };
|
||||||
|
|
||||||
configDir = {
|
productInfoPath =
|
||||||
"vscode" = "Code";
|
if pathExists "${cfg.package}/lib/vscode/resources/app/product.json" then
|
||||||
"vscode-insiders" = "Code - Insiders";
|
# Visual Studio Code, VSCodium
|
||||||
"vscodium" = "VSCodium";
|
"${cfg.package}/lib/vscode/resources/app/product.json"
|
||||||
"openvscode-server" = "OpenVSCode Server";
|
else
|
||||||
}.${vscodePname};
|
# OpenVSCode Server
|
||||||
|
"${cfg.package}/product.json";
|
||||||
|
productInfo = lib.importJSON productInfoPath;
|
||||||
|
|
||||||
extensionDir = {
|
configDir = productInfo.nameShort;
|
||||||
"vscode" = "vscode";
|
extensionDir = productInfo.dataFolderName;
|
||||||
"vscode-insiders" = "vscode-insiders";
|
|
||||||
"vscodium" = "vscode-oss";
|
|
||||||
"openvscode-server" = "openvscode-server";
|
|
||||||
}.${vscodePname};
|
|
||||||
|
|
||||||
userDir = if pkgs.stdenv.hostPlatform.isDarwin then
|
userDir = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
"Library/Application Support/${configDir}/User"
|
"Library/Application Support/${configDir}/User"
|
||||||
|
@ -37,7 +35,7 @@ let
|
||||||
snippetDir = "${userDir}/snippets";
|
snippetDir = "${userDir}/snippets";
|
||||||
|
|
||||||
# TODO: On Darwin where are the extensions?
|
# TODO: On Darwin where are the extensions?
|
||||||
extensionPath = ".${extensionDir}/extensions";
|
extensionPath = "${extensionDir}/extensions";
|
||||||
|
|
||||||
extensionJson = pkgs.vscode-utils.toExtensionJson cfg.extensions;
|
extensionJson = pkgs.vscode-utils.toExtensionJson cfg.extensions;
|
||||||
extensionJsonFile = pkgs.writeTextFile {
|
extensionJsonFile = pkgs.writeTextFile {
|
||||||
|
|
9
tests/modules/programs/vscode/fake-pkg.nix
Normal file
9
tests/modules/programs/vscode/fake-pkg.nix
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
pkgs.writeTextFile {
|
||||||
|
name = "fake-vscode";
|
||||||
|
destination = "/lib/vscode/resources/app/product.json";
|
||||||
|
text = builtins.toJSON {
|
||||||
|
nameShort = "Code";
|
||||||
|
dataFolderName = ".vscode";
|
||||||
|
};
|
||||||
|
}
|
|
@ -66,7 +66,7 @@ in {
|
||||||
programs.vscode = {
|
programs.vscode = {
|
||||||
enable = true;
|
enable = true;
|
||||||
keybindings = bindings;
|
keybindings = bindings;
|
||||||
package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
|
package = import ./fake-pkg.nix pkgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
|
|
|
@ -42,7 +42,7 @@ let
|
||||||
in {
|
in {
|
||||||
programs.vscode = {
|
programs.vscode = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
|
package = import ./fake-pkg.nix pkgs;
|
||||||
globalSnippets = {
|
globalSnippets = {
|
||||||
fixme = {
|
fixme = {
|
||||||
prefix = [ "fixme" ];
|
prefix = [ "fixme" ];
|
||||||
|
|
|
@ -32,7 +32,7 @@ let
|
||||||
in {
|
in {
|
||||||
programs.vscode = {
|
programs.vscode = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
|
package = import ./fake-pkg.nix pkgs;
|
||||||
userTasks = tasks;
|
userTasks = tasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ let
|
||||||
in {
|
in {
|
||||||
programs.vscode = {
|
programs.vscode = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
|
package = import ./fake-pkg.nix pkgs;
|
||||||
enableUpdateCheck = false;
|
enableUpdateCheck = false;
|
||||||
enableExtensionUpdateCheck = false;
|
enableExtensionUpdateCheck = false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue