nix-community / nixos-vscode-server

Visual Studio Code Server support in NixOS
MIT License
419 stars 76 forks source link

Modifying environment #52

Closed jmgilman closed 1 year ago

jmgilman commented 1 year ago

This is less of an issue and more of a general question. Is there a way to make the remote vscode server pickup the environment from a development shell? When attempting to do, for example, Python work, the IDE constantly complains about missing packages. The only recourse is to install them globally on the NixOS machine, which isn't really a viable option.

Any thoughts?

msteen commented 1 year ago

Not 100% sure, but if you replaced node via services.vscode-server.nodejsPackage with say a script that runs node through a development shell, vscode would have the environment of that node, so als long as your script has a /bin/node that is executable and eventually runs node proper, it might work out? Just brainstorming.

georgewhewell commented 1 year ago

i am using https://github.com/nix-community/lorri and this extension https://github.com/direnv/direnv-vscode

e.g put some minimal shell.nix with dependencies, then run lorri init && direnv allow in project dir. extension will prompt to reload using this env

jmgilman commented 1 year ago

Looks promising. I already use direnv but use the flake support for loading my devshell. Tried installing that extension and reloading but it didn't appear to do anything. Might not be supported.

georgewhewell commented 1 year ago

ah sorry, linked wrong extension: https://github.com/direnv/direnv-vscode

jmgilman commented 1 year ago

Ah, yeah I realized the other hadn't been updated in 7 years 😅

That one did the trick, thanks for the suggestion!