Nix Docker container with VS Code Remote

Hi all,

I’ve been tinkering with trying to get VS Code Remote Containers to work with the official docker image. I’m wondering if anyone has had success with this? It appears that VSCode ships with its own node version which, of course, doesn’t play well with Nix due to dynamic linking.

This is what I have so far:

FROM nixos/nix:2.8.0

# Install deps
RUN nix-env -i ncurses glibc gcc

## Enable flakes
RUN echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf

# Fixes
RUN mkdir /lib && \
    ln -s "$(ls /nix/store/*glibc*/lib/ | tail -1)" /lib/ && \
    echo "LD_LIBRARY_PATH=$(find /nix/store -name | tail -1 | xargs dirname)" >> /etc/environment

CMD /root/.nix-profile/bin/bash

The problem I’m running into is that I can’t get the VSCode to pick up the LD_LIBRARY_PATH when it connects to the container and so node complains about not finding libstdC++. I feel like I’m close but I tried all sorts of locations to get the environment variable to get picked up (i.e. /profile, ~/.bashrc, etc) but I haven’t figured it out.

Note I am running on arm64, but I planned on cleaning it up to be platform agnostic once I got it working.

Any tips or pointers?

Can this possibly help? VSCode Remote SSH Development With Nix - DZone Open Source

Thanks for the link. I did come across this one already, unfortunately, the solution that was chosen there is to use systemd to dynamically replace the node binary that VSCode uses. So, it wouldn’t work in the container context.