Jump to content

Visual Studio Code: Difference between revisions

Clarify the nix-shell section especially for beginners. Move section to installation for a more seamless installation process.
imported>Atry
No edit summary
imported>Jmarmstrong1207
(Clarify the nix-shell section especially for beginners. Move section to installation for a more seamless installation process.)
Line 85: Line 85:
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>
</syntaxHighlight>
=== Creating development environments using nix-shell ===
Instead of using configuration.nix to add packages (e.g. Python or NodeJS) for developing code on VSCode, you can instead use nix-shell. This will allow you to seamlessly create development environments with the correct packages for your project, without rebuilding and restarting NixOS. See [https://nixos.wiki/wiki/Development_environment_with_nix-shell this page] for further instructions in building nix-shell development environments.
The extension [https://marketplace.visualstudio.com/items?itemName=arrterian.nix-env-selector nix-env-selector] will make switching between different nix-shell environments within VSCode so you can switch between different coding projects easily. It has a guide for setting up nix-shell environments for VSCode.


=== Insiders Build ===
=== Insiders Build ===
Line 255: Line 260:
See https://github.com/nix-community/NixOS-WSL/issues/222 for the discussion about <code>wsl --exec</code> issue on NixOS-WSL.
See https://github.com/nix-community/NixOS-WSL/issues/222 for the discussion about <code>wsl --exec</code> issue on NixOS-WSL.
See https://github.com/microsoft/vscode-remote-release/issues/8305#issuecomment-1661396267 about the workaround.
See https://github.com/microsoft/vscode-remote-release/issues/8305#issuecomment-1661396267 about the workaround.
== Using nix-shell ==
Some features of VS Code, 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 VS Code itself to add dependencies.


== Troubleshooting ==
== Troubleshooting ==