Visual Studio Code: Difference between revisions

Malix (talk | contribs)
Malix (talk | contribs)
Updating extension versions: better way to run the script
 
Line 15: Line 15:
Extensions can be managed using the 'vscode-with-extensions' package:
Extensions can be managed using the 'vscode-with-extensions' package:


<syntaxHighlight lang=nix>
<syntaxhighlight lang="nix">environment.systemPackages = with pkgs; [
environment.systemPackages = with pkgs; [
   (vscode-with-extensions.override {
   (vscode-with-extensions.override {
     vscodeExtensions = with vscode-extensions; [
     vscodeExtensions = with vscode-extensions; [
Line 32: Line 31:
     ];
     ];
   })
   })
];
];</syntaxhighlight>
</syntaxHighlight>


Some examples here: [https://github.com/search?q=extensionFromVscodeMarketplace&type=code GitHub search for "extensionFromVscodeMarketplace"]
Some examples here: [https://github.com/search?q=extensionFromVscodeMarketplace&type=code GitHub search for "extensionFromVscodeMarketplace"]
Line 43: Line 41:
It's also possible to install VS Code via [[Home Manager]]:
It's also possible to install VS Code via [[Home Manager]]:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">programs.vscode = {
programs.vscode = {
   enable = true;
   enable = true;
   profiles.default.extensions = with pkgs.vscode-extensions; [
   profiles.default.extensions = with pkgs.vscode-extensions; [
Line 51: Line 48:
     yzhang.markdown-all-in-one
     yzhang.markdown-all-in-one
   ];
   ];
};
};</syntaxhighlight>
</syntaxhighlight>


* See for more options: [https://nix-community.github.io/home-manager/options.xhtml#opt-programs.vscode.enable Home Manager Manual: Options - programs.vscode]
* See for more options: [https://nix-community.github.io/home-manager/options.xhtml#opt-programs.vscode.enable Home Manager Manual: Options - programs.vscode]
Line 178: Line 174:
== Updating extension versions ==
== Updating extension versions ==


Nixpkgs contains a script which will run <code>code --list-extensions</code>, then look for the latest available versions of those extensions, and output a list which you can add to your Nix config in a format similar to the above. To use it, clone the [https://github.com/NixOS/nixpkgs nixpkgs repo from GitHub], and run: [https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh nixpkgs/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh]
The Nixpkgs vscode extensions directory contains [https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh a script] which use <code>code --list-extensions</code> and lookup the latest versions of those extensions to outputs a nix expression with a single <code>extensions</code> attribute of the same type as <code>extensionsFromVscodeMarketplace</code> inputs.


Example output:
To run it in your current directory:<syntaxhighlight lang="console">curl -fsSL https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh | sh</syntaxhighlight>


<syntaxHighlight lang=nix>
=== Example output ===
./nixpkgs/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh  
<syntaxhighlight lang="console">$ curl -fsSL https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh | sh
... # it does some fetching and then outputs the list...
{ extensions = [
{ extensions = [
   {
   {
Line 199: Line 194:
   }
   }
];
];
}
}</syntaxhighlight>
</syntaxHighlight>


== Remote SSH ==
== Remote SSH ==