libnix roadmap

19 jul 2024

motivation

status of native windows nix using MinGW from my series libnix

we also cover these topics:

  • libnix: why we picked MinGW vs. other solutions
  • general roadmap

libnix: MinGW vs. other solutions

making nix work native on windows there are a few options, here are a few updates reaching out to these communities:

Tvix

tvix is a rust reimplementation of the c++ nix implementation, recent news:

  • store implementation since last update
  • nix evaluation comes close to upstream c++ nix, however, still effort to get to 100%
  • not all builtins are supported yet
  • no builders yet
  • could be used to replace the tour of nix emscripten based backend but not much more

cosmopolitan

cosmopolitan developers on discord mentioned to me that they had tried porting nix with cosmopolitan:

ariel nunez: Bash on windows was only possible last year, after a lot of work by jart and contributors, and now Windows Terminal Preview can use it. I read my logs and last attempt to compile Nix was on August 2023, at that point in time we found out Nix used Boost and that was a blocker at the time.

MinGW

MinGW cross compiler setup:

  • using mingw cross compiler from nixos-wsl to build nix for windows
  • john ericson’s MinGW contributions are ongoing and promising ~early 2024

libnix: general roadmap

here is a list of things which need to be done still, see https://github.com/NixOS/nix/labels/windows for detailed tickets.

1. meson build system

  • in order to build nix on windows natively, we need a build system which is not tied to bash. therefore meson is a good candidate for this and there have been a couple of patches already.

2. create test suite for nix on windows

3. assemble prototype windows bootstrap system

  • make nix evaluate on windows use the store on c:\ and
  • get runProgram working to execute tools like git for fetchUrl
  • use third-party built tools from MSYS2 (not built by nix)

4. build ‘hello world’ nixpkgs-win

  • minimal nixpkgs like abstraction

    • instead of trying to adapt nixpkgs we should start small with our own stdenv with mingw to show how to use it

5. make nix + toolchain build from windows

  • use the prototype toolchain to built itself
  • adapt bash and unix favoring build systems into a windows world

6. nix installer / channel

7. cargo with nix support

libnix: future nix work

these items need to be done outside of the libnix funding but are still worth mentioning.

1. sandboxing

2. user environments (pure powershell environment)

  • source $HOME/.nix-profile/etc/profile.d/nix.sh for powershell

3. nix-daemon & multi user mode

  • nix-daemon

    • calls nix-build (with different UID/GID)
    • windows unix domain socket support can be used

4. nixos module system systemd like windows abstraction

  • the nixos module system creates systemd targets on linux and it would be nice if we had something similar for windows, see systemd equivalent on windows

5. store interoperability

6. usability & documentation

  • support nix repl
  • support man pages in nix build --help

summary

this is a short summary of libnix topics what we are aiming for till the end of 2024.

additional we think that llvm-mingw is a potent toolchain for windows which enables us to use fixPath.

article source