zimbatm / vscode-devcontainer-nix

WIP: VSCode remote container for Nix-based environments
Apache License 2.0
12 stars 2 forks source link
devcontainer nix vscode

vscode-devcontainer-nix

STATUS: alpha

For colleagues who insist on working on macOS and Windows. Even though all the binaries are built for, deployed and executed on Linux servers.

Visual Studio Core Remote - Containers is a feature that allows to create a docker-based development environment. VSCode will start the container and run all the commands inside of it.

This project's goal is to provide such container to work on Nix-based projects.

Usage

  1. Install the VSCode "Remote - Containers" plugin
  2. Copy this repo under .devcontainer in the target project

Then VSCode would start the container and drop you into the nix-based development environment.

How it works

The VSCode plugin:

Then it uses uses docker exec to copy and install supporting binaries into the container. This includes some bash scripts, a node program, .... The binaries are compiled to work on Ubuntu which means that /lib64/ld-linux-x86-64.so.2 must present, and a few other supporting libraries.

It needs:

All of this is pre-built by the docker-nixpkgs project into the nixpkgs/devcontainer image.

On Linux, the user must adjust the Dockerfile so that the UID and GID inside of the container match the user UID and GID. It looks like this could be automated. Right now there is this convention in the Dockerfile:

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

I think vscode auto-detects the user UID and GID and injects them at build time. To be confirmed.

TODO

Roadmap

  1. [x] Make it work
  2. [x] Pure nix-based docker container?
  3. [ ] It would be nice if the vs extensions could be composed together.