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:
This file has been truncated.
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.
1. Install NixOS as a WSL 2 distro. Currently there's a working repository [here](https://github.com/Trundle/NixOS-WSL).
2. Install Visual Studio Code and its Remote-WSL extension.
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 issues
- Every time your vscode updates (including the very first run), connection will fail. Just click 'retry' and reconnect. See `server-env-setup` file for explanations.
## Issue with [Trundle/NixOS-WSL](https://github.com/Trundle/NixOS-WSL) distro
You will likely run into this error:
What I found out:
This one works:
GitHub - Trundle/NixOS-WSL: NixOS on WSL(2) (and also thanks for mentioning it here) However it required some tweaks to make it work with VSCode. Currently there aren’t any Remote-SSH specific nor Remote-WSL specific issues. They share same issues, posted
in this thread. You can refer to that thread if you want another solution other than mine.
Hi!! Nice post, the last time I tried using Remote-SSH in my hyper-v, vscode cannot always detect because of this issue:
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