I did not find a way to effectively integrate devbox with vscode. As the broad majority of devs are using this editor these days, this is a concern for adoption in large teams.
You can start a devbox shell in the vscode terminal, but it does not set the env of all other vscode process (tasks, debugger, extensions...)
I feel like writing a devcontainer could be a great way to fix this (and free user for the required nix dependency), but I was not successful in implementing it.
@pomdtr We recently published the first version of devbox VSCode extension. We'll try to see if we can have the environment for the whole IDE (debugger & path to binaries and dependencies) be updated by the extension. Devcontainer seems like a possible solution as well. We'll update under this issue once we have a solution to move forward on this.
Cool ! Here is an interesting read on the devcontainer / nix integration: https://levelup.gitconnected.com/vs-code-remote-containers-with-nix-2a6f230d1e4e
I've got a draft version working for devbox. Please take a look at it: https://github.com/pomdtr/devbox-devcontainer
@pomdtr Thanks for sharing this. I don't have codespaces enabled on my github account but I tested it locally with Docker desktop and Dev Containers extension on VSCode and it woks great. Although, it runs vscode from inside a Docker container with a shared volume between the host machine and Docker. That means in a non-Linux OS there might be a performance hit.
That said, I really liked the Dev Containers extension when it detects a .devcontainer
it prompts with "Reopen this in devcontainers". Maybe we can add a similar functionality to Devbox's extension. Because if we open vscode from inside a devbox shell, the language binaries and interpreter settings in vscode will be set to devbox's shell environment.
I think the performance hit should be quite minimal since the bind mount only contains the workspace folder. There are way to mitigate the performance penalty (see : https://code.visualstudio.com/remote/advancedcontainers/improve-performance)
@mohsenari I have made some improvements on the template. The dependencies are now populated during the build, and the .devbox
dir is no longer in the workspace directory (since the symlinks only work in the container, it should not be synced with the host).
The only issue is that the devbox cli is no longer working in the container. It would be cool to add support for setting the .devbox
dir path via config.
Ex:
devbox --config .devcontainer/devbox.json --cache /devbox/.devbox
Ideally I would also like to be able to set these options using environment variable since it would allow me set them in the dockerfile:
ENV DEVBOX_CONFIG=.decontainer/.devbox.json
ENV DEVBOX_CACHE=/devbox/.devbox
Then the user would be able to use devbox add python310
inside the dev container. Currently I need to do this:
devbox --config /devbox/devbox.json add python310 && copy /devbox/devbox.json .devcontainer/devbox.json
Also a devbox install
command would be a better alternative to devbox shell --config /devbox/devbox.json -- echo "Devbox Store Populated"
.
Thanks a ton for improving the templates! to summarize your suggestions are:
.devbox/
dir path via config"--config
and --cache
flags using env variablesdevbox install
command as alternative to devbox shell --config /devbox/devbox.json -- echo "Devbox Store Populated"
I'll make separate issues for them to track each independently.
@pomdtr I looked at the Dockerfile, there is not much feedback I have on making it faster. Nix installation takes some time and also first time running devbox shell
after a new installation also takes time due to Nix copying stuff to /nix/store
. So One idea is to have everything before calling devbox shell
and publish it as a public Docker image. That way Nix and devbox get cached as a layer and subsequent runs won't install nix and devbox. Other than that, the Dockerfile looks ok imo.
For moving .devbox/
out of the workspace dir, I don't think it is supported as of now. But if there is a reason other than preference for it, we can prioritize implementing it similar to --config
for custom devbox.json path.
@pomdtr we have added a feature to the VSCode extension that can generate a .devcontainer.json file and Dockerfile that works with your Devbox project. If you have a chance to try it out, we'd love your feedback on how it works! Closing this comment for now, but can reopen if there are any issues with the Extension
Owner Name | jetpack-io |
Repo Name | devbox |
Full Name | jetpack-io/devbox |
Language | Go |
Created Date | 2022-08-18 |
Updated Date | 2023-03-31 |
Star Count | 4960 |
Watcher Count | 19 |
Fork Count | 68 |
Issue Count | 42 |
Issue Title | Created Date | Updated Date |
---|