Visual Studio Code: Difference between revisions
Option renamed: extensions -> profiles.default.extensions |
→Updating extension versions: better way to run the script |
||
(2 intermediate revisions by the same user not shown) | |||
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">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> | ||
</ | |||
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 58: | Line 54: | ||
=== Non-NixOS === | === Non-NixOS === | ||
{{Warning|Use of nix-env is not recommended}}<syntaxHighlight lang="console"> | |||
<syntaxHighlight lang="console"> | |||
$ nix-env -iA nixos.vscode | $ nix-env -iA nixos.vscode | ||
</syntaxHighlight> | </syntaxHighlight> | ||
Line 83: | Line 78: | ||
Adding extension-specific dependencies, these will be added to the FHS environment: | Adding extension-specific dependencies, these will be added to the FHS environment: | ||
< | <syntaxhighlight lang="nix"> | ||
# needed for rust lang server and rust-analyzer extension | # needed for rust lang server and rust-analyzer extension | ||
programs.vscode.package = pkgs.vscode.fhsWithPackages (ps: with ps; [ rustup zlib openssl.dev pkg-config ]); | programs.vscode.package = pkgs.vscode.fhsWithPackages ( | ||
</ | ps: with ps; [ | ||
rustup | |||
zlib | |||
openssl.dev | |||
pkg-config | |||
] | |||
); | |||
</syntaxhighlight> | |||
=== Insiders Build === | === Insiders Build === | ||
Line 172: | Line 174: | ||
== Updating extension versions == | == Updating extension versions == | ||
Nixpkgs contains | 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. | ||
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> | |||
< | === Example output === | ||
<syntaxhighlight lang="console">$ curl -fsSL https://raw.githubusercontent.com/NixOS/nixpkgs/master/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh | sh | |||
{ extensions = [ | { extensions = [ | ||
{ | { | ||
Line 193: | Line 194: | ||
} | } | ||
]; | ]; | ||
} | }</syntaxhighlight> | ||
</ | |||
== Remote SSH == | == Remote SSH == |