Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jul1u5 opened this issue Oct 28, 2019 · 6 comments
Closed

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

jul1u5 opened this issue Oct 28, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@jul1u5
Copy link
Contributor

jul1u5 commented Oct 28, 2019

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:

  • Execute the command multiple times
  • Run the command only once and specify multiple packages separated by space. It might be difficult to implement auto-completion for every package, although I don't know how VSCode API for extension commands looks like.

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.

@jul1u5 jul1u5 added the enhancement New feature or request label Oct 28, 2019
@arrterian
Copy link
Owner

arrterian commented Oct 28, 2019

@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.

  • Finding and autocompletion packages from nixpkgs by separate command
  • Ability to generate an environment for particular workspace in fly with a couple of commands

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
Copy link
Contributor Author

jul1u5 commented Nov 12, 2019

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.

  • Should the command figure out where to put the dependency in the file all by itself? That seems quite complicated, because, for instance, there could be buildInputs, buildNativeInputs lists specified in the file.
  • Perhaps VS Code could parse shell.nix file and add the package to buildInputs list by default. If there is no buildInputs specified, the command could show a warning. However, implementing the parser for the Nix language would complicate the project a lot, wouldn't it?

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
Copy link
Owner

arrterian commented Nov 24, 2019

@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
Copy link
Contributor Author

jul1u5 commented Nov 24, 2019

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

@blaggacao
Copy link

blaggacao commented Feb 9, 2021

This should be doable via devshell's toml file.

@arrterian
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants