Visual Studio Code: Difference between revisions
imported>Mic92 remote-ssh is now available upstream |
imported>Jonringer Add information on using fhs variant of vscode |
||
Line 67: | Line 67: | ||
== Using nix-shell == | == Using nix-shell == | ||
Some features of VSCode, like the Python package, require linters or other dependencies. The package [https://marketplace.visualstudio.com/items?itemName=arrterian.nix-env-selector nix-env-selector] makes this easy and does not require overrides on vscode itself to add dependencies. | Some features of VSCode, like the Python package, require linters or other dependencies. The package [https://marketplace.visualstudio.com/items?itemName=arrterian.nix-env-selector nix-env-selector] makes this easy and does not require overrides on vscode itself to add dependencies. | ||
== Use VSCode extensions without additional configuration == | |||
{{note| Only available in nixpkgs-unstable or 21.05 and after }} | |||
In [https://github.com/NixOS/nixpkgs/pull/99968 #99968], a vscode-fhs and vscodium-fhs package were added in which vscode launches inside of a [https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard FHS] compliant chroot environment using buildFHSUserEnv. This reintroduces directories such as /bin, /lib/, and /usr, which allows for extensions which ship pre-compiled binaries to work with little to no additional nixification. | |||
{{note| From a philosophical view, use of buildFHSUserEnv allows for ease-of-use at the cost of some impurity and non-reproducibility. If you prioritize purely-declarative configurations, please stay with the above guidance.}} | |||
Example usage: | |||
<syntaxHighlight lang=console> | |||
$ nix-shell -p vscode-fhs --run code | |||
</syntaxHighlight> | |||
Home-manager: | |||
<syntaxHighlight lang=nix> | |||
programs.vscode.enable = true; | |||
programs.vscode.package = pkgs.vscode-fhs; | |||
</syntaxHighlight> | |||
Adding extension-specific dependencies, these will be added to the FHS environment: | |||
<syntaxHighlight lang=nix> | |||
# needed for rust lang server extension | |||
programs.vscode.package = pkgs.vscode-fhsWithPackages (ps: with ps; [ rustup zlib ]); | |||
</syntaxHighlight> |