Nix on Windows?

Yea can’t do cross compilation atm, the programs can only be compiled with visual studio. Lots of programs are like this like Nodejs addons.

You can cross compile Nix itself though, and then build other things natively with Nix on Windows.

2 Likes

I’m looking forward to Windows support. I rather not using VM or WSL2 just to run a small program I needed

2 Likes

There’s one benefit of supporting windows that I can’t stop thinking about:

Library creators sometimes need non-library external applications that they run internally (for example an image manipulation library might call imagemagick under the hood). Such external dependencies are usually not handled by the languages package manager very well. For NPM packages for example, the packages usually have their own scripts to download such applications as pre built binaries from somewhere for the specific platform they’re currently on, which means a lot of trouble when nixifying such packages.

The solution would be simple: Provide package creators a way of defining such dependencies with nix, and when nixifying the package, this could be respected. Nice! This could be so convenient, that it quickly could become the default way of dealing with this. The only problem: if it doesn’t work on windows as well, they’ll still have to do it manually there. And then, why even bother with nix?

If nix worked on windows this would not be a problem, and package creators could focus completely on specifying dependencies with nix. This would dramatically simplify building packages with nix in the long run and would also benefit Linux and Mac.

12 Likes

My use case is that I want:

  • to have one repo where my nix source lives.
  • I want this source to setup my workstations, servers, etc
  • I want this source to run on windows, Linux, and Mac. where i want it to configure those platforms.
  • I only expect to create small wrapper tools curl blah | sh or the powershell iex equiv to kick start the setup on a fresh machine.

I read a lot about people claiming “omg it works on windows via wsl2”, but when you look at what they’re doing… it’s no different to what they do on linux, completely disregarding the configuration and provisioning of the windows side of things.

I had seen only one mention so far (in this thread i think) that since you could execute windows binaries from within wsl2, that there could perhaps be a way to make nix do windows configuration that way ?

3 Likes

OK some progress updates:

Ready/merged:

Next major milestone:

21 Likes

Two more PRs split out from Build unit tests with MinGW by Ericson2314 · Pull Request #8901 · NixOS/nix · GitHub

7 Likes

I’d also like to thanks @wegank a lot for helping out with getting readline working on Windows, so we can (hope to) have a nix repl. That is the final dependency that needed Nixpkgs porting help (since we are skipping lowdown for now).

The number of Nixpkgs PRs and backports for this is rather dizzying, so I won’t link them here :D.

16 Likes

There is now a matrix discussion channel for this effort #windows:nixos.org!

(@Ericson2314 is rate-limited in this thread, and so asked me to post this message on his behalf.)

2 Likes

Thanks @Qknight!

The first big news since that has happened is that @puffnfresh made some further progress: Brian McKenna: "Now got a #nix-instantiate.exe - ending my work t…" - Mastodon and previous posts.

15 Likes

This looks like great starts…
Do we have a project github where we can share on this?
e.g.
- Considering system packages/features (terminology changes between workstation and server versions for no good reason via DISM.exe)

  • Pursuing is (beta/preview) M$/Pwsh DSC (Desired State Configuration) becomes useful enough to add to Nix on windows.

Thanks!

There is

A little confused, but GitHub - PowerShell/DSC: This repo is for the DSC v3 project sure that is worth knowing about. I assume this is more an ansible/chef/puppet type thing?

2 Likes

I think maybe she’s excited about the possibility of an impure Nix module system for Windows, like Nix-Darwin is for macOS, where the parts that require configuring the underlying OS could rely on DSC.

But yeah, DSC is like Puppet or Chef. It’s an interface for defining configuration options that can be invoked declaratively, but it’s basically powered by bits of PowerShell scripts and it’s on the authors of DSC modules (or whatever they’re called) to ensure those scripts behave idempotently.

5 Likes

And thanks for the nix-darwin comparison. I get it better now.

1 Like

Thanks for the clarification I was also confused but this makes sense.

And thank you for your work everyone! I’m very excited for the doors this will open, even if I don’t use windows myself. Godspeed!

6 Likes

We have a beachhead, Build a minimized Nix with MinGW by Ericson2314 · Pull Request #8901 · NixOS/nix · GitHub is merged!

With that, the work can hopefully proceed in parallel. To kick things off, I’ve opened issues:

Some of them are quite small and self-contained and would be excellent first issues for new contributers!

30 Likes

wait, wasn’t Moby Dick a sperm whale :wink: this is great news - is there a “quick start” for someone having never done it to get what you’ve accomplished setup on Windows? I can fumble around in the dark but probably won’t find it. Anyway, very exciting.

@Qknight posted libnix mingw status just before it was merged, which has some instructions for trying things out.

Of course, we’ll want to make it easier and better tested next!

7 Likes

Nix is going to eat the world! This is huge!

7 Likes

Thanks for this! I got stuck but will try again soon

1 Like