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.
I’m looking forward to Windows support. I rather not using VM or WSL2 just to run a small program I needed
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.
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 powershelliex
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 ?
OK some progress updates:
Ready/merged:
- Allow getting in a MinGW dev shell by Ericson2314 · Pull Request #9519 · NixOS/nix · GitHub : Makes it possible to do development with ease from Linux and Darwin!
- Allow installing unit tests by Ericson2314 · Pull Request #9360 · NixOS/nix · GitHub : Allow installing the unit tests so we can cross compile them and run them elsewhere.
-
Make lowdown optional by wegank · Pull Request #9710 · NixOS/nix · GitHub : Until Build failure with MinGW · Issue #130 · kristapsdz/lowdown · GitHub is fixed, we cannot build
lowdown
for windows. This makes the dep optional to avoid that for now. -
Improve build sytem support for readline instead of editline by Ericson2314 · Pull Request #9728 · NixOS/nix · GitHub : Better build system support for readline instead of editline (will allow interactive
nix repl
on Windows).
Next major milestone:
- Build unit tests with MinGW by Ericson2314 · Pull Request #8901 · NixOS/nix · GitHub : Draft PR taking a subset of @volth’s work and pairing it down to just focus on building the unit tests successfully.
Two more PRs split out from Build unit tests with MinGW by Ericson2314 · Pull Request #8901 · NixOS/nix · GitHub
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.
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.)
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.
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
-
this issue Windows MinGW support · Issue #1320 · NixOS/nix · GitHub
-
this label Issues · NixOS/nix · GitHub
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?
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.
And thanks for the nix-darwin comparison. I get it better now.
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!
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:
- Rename `SearchPath` · Issue #10539 · NixOS/nix · GitHub
- Implement `setStackSize` on Windows · Issue #10540 · NixOS/nix · GitHub
- Use portable C++ Pseudorandom number generator · Issue #10541 · NixOS/nix · GitHub
- Abstract over `getrusage` · Issue #10542 · NixOS/nix · GitHub
- Implement `updateWindowSize` on windows · Issue #10543 · NixOS/nix · GitHub
- Implement process spawning on Windows · Issue #10544 · NixOS/nix · GitHub
- Implement `PathLocks` on windows · Issue #10545 · NixOS/nix · GitHub
- Run unit tests in Wine in CI · Issue #10547 · NixOS/nix · GitHub
Some of them are quite small and self-contained and would be excellent first issues for new contributers!
wait, wasn’t Moby Dick a sperm whale 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!
Nix is going to eat the world! This is huge!
Thanks for this! I got stuck but will try again soon