Now that WSL 2 (Windows Subsystem for Linux) has been released from Windows 2004 update, NixOS can be run in Windows machine
I quickly searched for a way to develop with VSCode Remote-WSL extension, which makes it possible to develop within Windows while testing & running in NixOS, in a single machine. However, no one has posted about this, so I decided to quickly share how I managed to build the environment.
Quick guide to work with Remote-WSL:
# 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
1. Install NixOS as a WSL 2 distro. Currently there's a community supported repository here ([NixOS-WSL](https://github.com/nix-community/NixOS-WSL)).
2. Install Visual Studio Code and its [Remote-WSL](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) extension.
3. Make sure your NixOS system have `wget` installed. If you have no idea on this, run `nix profile install nixpkgs#wget` command to install `wget`.
4. Run `cp ./server-env-setup ~/.vscode-server/server-env-setup`. See [here](https://code.visualstudio.com/docs/remote/wsl#_advanced-environment-setup-script) for description.
5. 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
This file has been truncated. show original
What I found out:
2 Likes
Rizary
May 31, 2020, 10:55am
2
Hi!! Nice post, the last time I tried using Remote-SSH in my hyper-v, vscode cannot always detect because of this issue: Does not work if target is a nixos · Issue #648 · microsoft/vscode-remote-release · GitHub
I’ll try this today. Thanks again!
That’s outstanding… It would have never happened in the Guix world…
That’s really cool @sonowz ! Thanks you for testing and sharing this!
I’m going to try it against the redistributable NixOS version I’ve forked (https://github.com/Elyhaka/NixOS-WSL/releases/tag/0.0.2 / https://github.com/Elyhaka/NixOS-WSL-DistroLauncher )
I’ll see if I can integrate it directly inside the redistributable version.
We’re getting closer on NixOS support over Windows
3 Likes