Got NixOS running in WSL (Windows Subsystem for Linux)

As apart of my journey to learn what Nix can do, I’ve created a Nix rootfs that can be loaded into WSL (Windows Subsystem for Linux). I’m keeping instructions here:

Feel free to try it out, provide experiences, correct me on things.

10 Likes

Great work! Note that this is just installing the Nix package manager. NixOS is not installed so you won’t be able to use nixos-rebuild / etc. to manage it. It’s still useful and an easy way to get Nix installed. But we definitely could use a WSL module in NixOS to generate this stuff. We already have something similar through boot.isContainer but adding stuff to generate the rootfs.tar.gz would be nice. Ideally we could get all of this on the Microsoft Store as well.

5 Likes

See also this previous effort:

Which is apparently blocked by

It is likely your setup is, too, affected by this; and possible that you haven’t been hit by it yet.

1 Like

Yeah it looks like WSL has issues if you have question mark ‘?’ characters in your path names. In my setup I didn’t have any so I’ve dodged that issue for now.

Thanks for the pointers into what’s already been done, I’ll have to take a look.

1 Like