WSL 2 is out. Better support for Nix

I think this will solve our sqlite options with Nix. So nix should be install and go!

Also, I think we can run systemd now, as wsl2 supports Cgroups. This means we can run NixOS on WSL!

15 Likes

https://mybuild.techcommunity.microsoft.com/sessions/77003 is also worth watching for all the technical details.

Nix should now work great on another distro like Ubuntu.

For NixOS support it’s a bit more complicated than because they ship and run the linux kernel and init system. From the presentation it wasn’t clear what init they were using.

So, that would be running stuff inside a NixOS container inside an Ubuntu virtualized on Windows? We’re getting a bit deep.

Yes and wine should work great as well :smiley:

3 Likes

Don’t forget to enable build sandboxing, too.

Ideally it would just be NixOS using the WSL2 kernel … But I guess, that might be the easier route to nix on windows initially.

There’s still no systemd support but it looks like the big issues are solved? Blockers for systemd? · Issue #994 · microsoft/WSL · GitHub

I want a nixos-win which changes registry entries for me and allows me a reproducible windows.

3 Likes

Looks like somebody has gotten it working fully with systemd GitHub - nix-community/NixOS-WSL: NixOS on WSL(2) [maintainer=@nzbr]

7 Likes

Hello everyone,

I’ve been woking upon this project as a base on my spare time. I’ve modified GitHub - nix-community/NixOS-WSL: NixOS on WSL(2) [maintainer=@nzbr] to build a generic image where you can set your username (like in other WSL distros).

I’ve also plugged a GitHub Action to build the image and attach it as a release asset, its available here: https://github.com/Elyhaka/NixOS-WSL/releases/tag/0.0.2

Then, I’ve created the launcher for this image, you can find it as an artifact here: https://github.com/Elyhaka/NixOS-WSL-DistroLauncher/actions/runs/121288892

If you download the launcher.exe and the install.tar.gz in the same directory and then you execute the launcher.exe it should spawn a working NixOS setup.

This is a work in progress, there are a lot of issues in the current setup before building a redistributable appx.

EDIT: I’ve made a more complete post about it

16 Likes

Looks like WSL just got proper systemd support:

https://github.com/microsoft/WSL/issues/994

5 Likes

Nix in daemon mode works but I would prefer to use a proper NixOS without doing hacky thing, is there another known blocking issue that prevents deploying NixOS in WSL?

1 Like

There is already some testing going on to get native systemd support into nixos-wsl but you can already use it and the wrapper works really well.

1 Like