diff --git a/modules/programs/vscode.nix b/modules/programs/vscode.nix index f77937d66..027dfd3ab 100644 --- a/modules/programs/vscode.nix +++ b/modules/programs/vscode.nix @@ -11,19 +11,17 @@ let jsonFormat = pkgs.formats.json { }; - configDir = { - "vscode" = "Code"; - "vscode-insiders" = "Code - Insiders"; - "vscodium" = "VSCodium"; - "openvscode-server" = "OpenVSCode Server"; - }.${vscodePname}; + productInfoPath = + if pathExists "${cfg.package}/lib/vscode/resources/app/product.json" then + # Visual Studio Code, VSCodium + "${cfg.package}/lib/vscode/resources/app/product.json" + else + # OpenVSCode Server + "${cfg.package}/product.json"; + productInfo = lib.importJSON productInfoPath; - extensionDir = { - "vscode" = "vscode"; - "vscode-insiders" = "vscode-insiders"; - "vscodium" = "vscode-oss"; - "openvscode-server" = "openvscode-server"; - }.${vscodePname}; + configDir = productInfo.nameShort; + extensionDir = productInfo.dataFolderName; userDir = if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support/${configDir}/User" @@ -37,7 +35,7 @@ let snippetDir = "${userDir}/snippets"; # TODO: On Darwin where are the extensions? - extensionPath = ".${extensionDir}/extensions"; + extensionPath = "${extensionDir}/extensions"; extensionJson = pkgs.vscode-utils.toExtensionJson cfg.extensions; extensionJsonFile = pkgs.writeTextFile { diff --git a/tests/modules/programs/vscode/fake-pkg.nix b/tests/modules/programs/vscode/fake-pkg.nix new file mode 100644 index 000000000..40bee0f3a --- /dev/null +++ b/tests/modules/programs/vscode/fake-pkg.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: +pkgs.writeTextFile { + name = "fake-vscode"; + destination = "/lib/vscode/resources/app/product.json"; + text = builtins.toJSON { + nameShort = "Code"; + dataFolderName = ".vscode"; + }; +} diff --git a/tests/modules/programs/vscode/keybindings.nix b/tests/modules/programs/vscode/keybindings.nix index 64212e29a..4cbffaadd 100644 --- a/tests/modules/programs/vscode/keybindings.nix +++ b/tests/modules/programs/vscode/keybindings.nix @@ -66,7 +66,7 @@ in { programs.vscode = { enable = true; keybindings = bindings; - package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; }; + package = import ./fake-pkg.nix pkgs; }; nmt.script = '' diff --git a/tests/modules/programs/vscode/snippets.nix b/tests/modules/programs/vscode/snippets.nix index a7ea44f76..a9adea329 100644 --- a/tests/modules/programs/vscode/snippets.nix +++ b/tests/modules/programs/vscode/snippets.nix @@ -42,7 +42,7 @@ let in { programs.vscode = { enable = true; - package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; }; + package = import ./fake-pkg.nix pkgs; globalSnippets = { fixme = { prefix = [ "fixme" ]; diff --git a/tests/modules/programs/vscode/tasks.nix b/tests/modules/programs/vscode/tasks.nix index ea85b3d6c..25e0e65ef 100644 --- a/tests/modules/programs/vscode/tasks.nix +++ b/tests/modules/programs/vscode/tasks.nix @@ -32,7 +32,7 @@ let in { programs.vscode = { enable = true; - package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; }; + package = import ./fake-pkg.nix pkgs; userTasks = tasks; }; diff --git a/tests/modules/programs/vscode/update-checks.nix b/tests/modules/programs/vscode/update-checks.nix index 1547bd36a..c6351a987 100644 --- a/tests/modules/programs/vscode/update-checks.nix +++ b/tests/modules/programs/vscode/update-checks.nix @@ -17,7 +17,7 @@ let in { programs.vscode = { enable = true; - package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; }; + package = import ./fake-pkg.nix pkgs; enableUpdateCheck = false; enableExtensionUpdateCheck = false; };