arrterian / nix-env-selector

Allows switch environment for Visual Studio Code using Nix Package Manager.
MIT License
220 stars 29 forks source link

Rustup packages as settings packages #57

Closed michalfita closed 3 years ago

michalfita commented 3 years ago

Describe the bug

This is a corner case, but I'm improvising here not seeing right solution anywhere else. VSCode's Rust Extension requires presence of rustup. I've added "nixEnvSelector.packages": ["rustup"] to .vcode/settings.json, but VSCode Extension do not see rustup after restart. All happens with WSL and remote session.

To Reproduce

Steps to reproduce the behavior:

  1. Add "nixEnvSelector.packages": ["rustup"] to .vscode/settings.json
  2. Set environment to shell.nix
  3. Open source file in Rust
  4. VSCode still complaints it doesn't see rustup.

Expected behavior

Extension notices rustup and installs rls or rust-analyzer depending on settings.

Screenshots

image

Environment:

Additional context

Under normal circumstances my development environment would be just deb packages installed from Ubuntu repository or manual installation of rustup. However, in conditions I'm working on at the moment Nix is used for all development environment and I'm trying to figure out best way to use VSCode with this.

Running nix-shell -p rustup and then code . on WSL2 terminal session work - VSCode sees the rustup.

arrterian commented 3 years ago

Nix-shell file and packages options exclude each other. Please unset the nixFile parameter when using packages. Also, it seems you made a typo in the setting file path .vcode/settings.json -> .vscode/settings.json

michalfita commented 3 years ago

Also, it seems you made a typo in the setting file path .vcode/settings.json -> .vscode/settings.json

Typo corrected, I finger-typed it, not copy&pasted. I've added that to the existing settings.json.

Please unset the nixFile parameter when using packages.

Parameter of what? shell.nix is maintained in the repo and contains all project's dependencies - trick is I cannot add rustup there.

arrterian commented 3 years ago

@michalfita You can use either the nix packages list or nixFile, but not both simultaneously. It will not work via nix-shell CLI too. I can suggest you use parametrized nix-shell to split project dependencies and setting up your local environment.