arrterian / nix-env-selector

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

[Feature]: Allow to specify packages without nix file #12

Closed jul1u5 closed 3 years ago

jul1u5 commented 5 years ago

Is your feature request related to a problem? Please describe. Right now the quickest way of making VSCode aware of some packages you need to create a shell.nix file. This creates some friction when you want to check out some projects without creating new files.

Describe the solution you'd like I propose a new command that would function similarly to nix-shell -p. The command would ask for the name of the package and then load it into the environment. Ideally, the command could display a list of packages from nixpkgs and filter it out as you type the name of the package.

I am not sure what could be the best way to add multiple packages:

Describe alternatives you've considered An alternative is to use nix-shell -p in the terminal and then start VSCode from the same nix-shell.

Additional context I think the specified packages could be saved in an array in .vscode/settings.json. Also, thanks for the extensions. It works really well.

arrterian commented 5 years ago

@jul1u5 Hi, thank you for the enhancement proposal. In the current feature request, I found a couple of reasonable ideas for the further evolution of the extension.

Staff that should be considered implemented another way I think it's no so good idea to save a list of configured packages in .vscode workspace setting file. The reason is duplication places where the packages can be listed. Will better to generate <config>.nix file as output for the command if not exist yet and modify existed when the package list should be updated.

PS: Appreciate your feedback and welcome to the discussion 🙂

jul1u5 commented 4 years ago

Hi, @arrterian, sorry for the delay. I have given some thought to your idea of generating some <config>.nix file instead of putting the list of packages in .vscode/settings.json file. Single-source of truth seems more desirable. However, I have thought of some edge-cases:

Suppose a project already contains a shell.nix file.

Just for reference when using, for example, nix-shell -p tree the shell will ignore any .nix files in the directory, and only load tree together with the current user environment. Maybe it wouldn't be that bad to put the package list in the .vscode directory? The user could still see where the packages are loaded from when using Select Environment command. If some file like shell.nix is already selected (instead of an internal environment in .vscode dir), the command for adding packages would refuse to add them and display a warning.

What are your thoughts?

arrterian commented 4 years ago

@jul1u5 I think the way storing packages for nix-shell -p in .vscode/settings.json is most comfortable and fast to implement.

For now, I am rewriting the extension to Purescript. It reasonable to proceed with adding new features after the rewriting process will end.

jul1u5 commented 4 years ago

That's cool. Let me know when you finish the rewrite. I can help with implementing this feature.

blaggacao commented 3 years ago

This should be doable via devshell's toml file.

arrterian commented 3 years ago

Added in #44 Released in v1.0.0 Please, read CHANGELOG.md for more info.