Vscode remote development on NixOS

Has anyone configured a NixOS box to serve as a host for vscode remote development yet?


Please post here if you have found anything!

I haven’t dug into this too much yet, but it looks like vscode installs a bunch of binaries on the remote server under the users account. This might not be trivial to get working under nixos and unfortunately I haven’t had the time to work on it yet. Very unfortunate as this would be high value to me.

If any vscode on nixos gurus are reading please shed any insight you can.


Thank you for your reply, yes, I will post anything I find!

Has anyone tried doing this? From reading the docs it seems like it should work without much trouble.

NixOS tends to have trouble running unpatched binaries. One of my devs tried without success but I can’t recall the error he reported. I’ll follow up and post the error here later today.

you should probably ping Geoffrey: https://twitter.com/GeoffreyHuntley/status/1143064069244506112

1 Like

Why don’t you open an issue upstream requesting the source code to compile the binaries? It is ofc up to you but IMO putting any minute into the closed source parts of VS code is not worth the time.

I’ve tried a few combinations of this so far. Attached you’ll find some configurations from my current iteration which is an ubuntu box with nix which would work 1:1 on a nixos machine after converting below to expressions.

  1. Take the vouch configuration above, combine with https://github.com/vouch/vouch-proxy , configure it to authenticate with GitHub oauth and run as a docker container.
  2. Take the above nginx configuration (adapt to a nix expression as need be) which denies unauthenticated requests and redirects to vouch.
  3. Take the above docker configuration of https://github.com/cdr/code-server and adapt it.

Enjoy. If you want to remove docker from the equation and build up an end-to-end nix expression of above (share it if you do) then use https://github.com/moretea/yarn2nix with https://github.com/cdr/code-server.

1 Like

The other combination that’s worth checking out is how I’m shipping nix w/vscode (mac, windows and linux) seamlessly to evaporate getting started friction w/learning haskell. Pull down this PR https://github.com/data61/fp-course/pull/340 and/or just click this link https://gitpod.io/#https://github.com/data61/fp-course

and finally using vscode (desktop) and the remote feature to a nixos server wasn’t working last time I checked. See https://github.com/microsoft/vscode-remote-release/issues/124

The latest release has fixed the above issue and resolved issues w/alpine containers meaning in theory up can use the .devcontainer/Dockerfile feature with https://github.com/nix-community/docker-nix or connect to a remote nixos server. I haven’t revisited this yet. Report back :slight_smile:

Thank you for your detailed response! I am busy with other tasks right now but let me try once I get to other things done.

1 Like

It looks like there is a solution to this problem: https://github.com/microsoft/vscode-remote-release/issues/648#issuecomment-503148523

A big thank you to @simonchatts for looking into this and coming up with a workaround. Hopefully @wmertens comment in the thread will receive a bit more attention so we can get a proper solution, instead of a workaround.


I just tried the solution proposed by @simonchatts and it worked on my server.