vscode-remote-wsl-nixos
vscode-remote-wsl-nixos copied to clipboard
Develop using VSCode Remote-WSL environment with NixOS
vscode-remote-wsl-nixos
Now that WSL 2 has been released from Windows 2004 update, NixOS can be run in Windows machine :tada: Since NixOS differs from other Linux in some aspects, it has some difficulties working with Visual Studio Code Remote-WSL extension. This repository quickly fixes problems working with VSCode.
Steps
- Install NixOS as a WSL 2 distro. Currently there's a community supported repository here (NixOS-WSL).
- Install Visual Studio Code and its Remote-WSL extension.
- Make sure
wget
is installed in your NixOS as a system package. If you have no idea on this, runnix profile install nixpkgs#wget
command to installwget
. - Run
cp ./server-env-setup ~/.vscode-server/server-env-setup
. See here for description. - Now VSCode can connect to your NixOS!
Known issue
Every time your vscode gets updated (including the very first run), the remote connection will fail. Just click 'retry' and reconnect.
This is a wontfix issue. See server-env-setup
script for explanations.
For non-flake users
Since NixOS-WSL includes flakes as default, non-flake is considered as legacy.
Please use non-flakes/server-env-setup file instead of server-env-setup
.
Alternative Solution
Solution described in this post works by setting up server-env-setup
file using home-manager. (This also requires nix-ld)