Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NixOS in Windows Store for Windows Subsystem for Linux (WSL) #30391

Closed
ThomasMader opened this issue Oct 13, 2017 · 77 comments
Closed

NixOS in Windows Store for Windows Subsystem for Linux (WSL) #30391

ThomasMader opened this issue Oct 13, 2017 · 77 comments
Labels
6.topic: windows Running, or buiding, packages on Windows

Comments

@ThomasMader
Copy link
Contributor

Nix already runs in Ubuntu via WSL afaik.
I think it would make sense to add an official NixOS image to the Windows Store.
Arch Linux is trying already. (microsoft/WSL#2253)

Are there any showstoppers?

@bencoman
Copy link

bencoman commented Oct 15, 2017

This would be super cool. I'd like to move to using NixOS, but I can't give up my Windows machine, and I don't want to run NixOS in a virtual machine. What I'd really like to try doing is a continuous integration system using NixOS based build management to kick off compilation on the Windows side.

#28365 is an impediment, but drilling through the linked issue I saw an update yesterday from a MS staffer that they have been working on it.

Also I'm not sure if NixOS/nix#1203 is the same or different root issue.

@PierreR
Copy link
Contributor

PierreR commented Oct 25, 2017

By the way, I have a permssion denied just after the creation of /nix when I try to install nix on WSL
nix

Any idea ?

@jtojnar
Copy link
Member

jtojnar commented Oct 25, 2017

@PierreR I also had this problem. I solved it by downloading the archive and copying the files to the directory manually.

@PierreR
Copy link
Contributor

PierreR commented Oct 26, 2017

@jtojnar Thanks ! Indeed if I run each problematic mv myself, it is going to work.

Any idea where the issue is coming from. I would like to streamline that process but it is going to be a bit cumbersome if such issue lingers on.

@PierreR
Copy link
Contributor

PierreR commented Oct 26, 2017

Just for the record I have hit microsoft/WSL#1671. Not only WSL seems to be unbearably slow, it would also fail strangely with this error:

error: setting synchronous mode: disk I/O error

My feeling is that WSL is too beta and adding an official NixOS image to the Windows Store might be premature.

@jtojnar
Copy link
Member

jtojnar commented Oct 26, 2017

@PierreR disk I/O error is NixOS/nix#1203

@PierreR
Copy link
Contributor

PierreR commented Oct 27, 2017

@jtojnar yes it is. Thanks ! Everything works fine for me except for the sluggishness.

@CMCDragonkai
Copy link
Member

Does NixOS the distro itself require anything special beyond what Ubuntu as a distro requires? If not, then it should be possible to get NixOS (and not just nix) onto WSL!

@benley
Copy link
Member

benley commented Dec 28, 2017

NixOS the distro relies pretty heavily on systemd to run services. It would still be great to use nixos-rebuild for building the user environment and making software available, but without systemd it would be difficult to use any nixos modules that expect to run daemons or cronjobs.

@Ericson2314 Ericson2314 added 6.topic: windows Running, or buiding, packages on Windows and removed 6.topic: windows Running, or buiding, packages on Windows labels Dec 29, 2017
@mdekstrand
Copy link
Contributor

NixOS the distro relies pretty heavily on systemd to run services. It would still be great to use nixos-rebuild for building the user environment and making software available, but without systemd it would be difficult to use any nixos modules that expect to run daemons or cronjobs.

Other distros will be in the same boat for any required services, but I can see this being a particular problem for Nix with the Nix Daemon.

Since WSL is intended to be a single-user environment, a NixOS that runs like single-user Nix could be what is needed to make it work.

@WSLUser
Copy link

WSLUser commented Mar 6, 2018

I would love to see another distro in the Windows Store. It only took Kali a couple months from request to publishing into the Windows Store (which released 3/5/2017 for record). Note that you can manually run any services as most of the syscalls are supported though I'm not too familiar with NixOS to guess what specifics might not exist yet in WSL. So while systemd won't automatically run the Nix Daemon, it's entirely possibly you "may" be able to manually run it. Do an strace and place a bug on WSL if there are any errors specific to WSL. And since emphasis is on systemd running, see microsoft/WSL#534, microsoft/WSL#1579, microsoft/WSL#2530 and vote for this UserVoice

Also try to use the latest Insider as it will greatly help in discovering what issues may still exist. For instance, you're able to perform background tasks on Insider.

@ThomasMader
Copy link
Contributor Author

Microsoft open sourced a WSL Sample for Linux Distribution maintainers. Might be very helpful.
https://blogs.msdn.microsoft.com/commandline/2018/03/26/wsl-distro-launcher/

@WSLUser
Copy link

WSLUser commented Apr 25, 2018

Any news in this front? I'd manually compile myself to test it out but won't have time for it for awhile. If anybody on the NIXOS team is running build 17134 SCU (pre-release still), if they could give it a go on this build, it would be appreciated.

@ghuntley
Copy link
Member

@ghuntley
Copy link
Member

I'm taking a stab at this. Initial success so far @ https://twitter.com/GeoffreyHuntley/status/995977211176927232

@ghuntley
Copy link
Member

Blocked by microsoft/WSL#3207

@PerArneng
Copy link

Thanks for the work on this. Testing out linux distros on Windows is really easy now days and you can run several side by side. Getting NixOS on to the app store could be a great gateway drug to NixOS and the excellent Nix package manager.

@ghuntley
Copy link
Member

ghuntley commented Aug 8, 2018

In private discussions with Microsoft about getting NixOS into the Microsoft App Store. Have been a little overwhelmed recently but it's high on my todo list. Microsoft are waiting on me.

@bencoman
Copy link

bencoman commented Aug 8, 2018 via email

@ghuntley
Copy link
Member

ghuntley commented Oct 25, 2018

Considering nixcon is on; it only makes sense to pick this back up again. I had to park it because I was overcommitted. Let's start this back up again.

screen shot 2018-10-25 at 9 18 01 pm

Next steps are as follows:

  • NixOS Foundation to sign up for a "Company" Windows Developer Account
  • NixOS Foundation to review contracts and execute them
  • Obtain testing plan from Microsoft
  • Obtain publishing and release plan from Microsoft
  • Productionise the NixOS build of install.tar.gz and embed into an appx.
  • Distribute the appx to microsoft
  • Party

@matthewbauer
Copy link
Member

matthewbauer commented Nov 3, 2018

What's the structure of install.tar.gz? I couldn't find that documented. Also, someone using WSL might want to add a package for "wslu" which has some nice things for interacting between Linux and Windows:

https://github.com/wslutilities/wslu

@zimbatm
Copy link
Member

zimbatm commented Nov 3, 2018

@ghuntley do you have a URL for the NixOS Foundation to review the documents?

@hypersw
Copy link
Contributor

hypersw commented Nov 25, 2018

Thanks for pushing NixOS towards running over WinNT! That would be handy.

The roadmap above is much about putting NixOS into the appstore. Which is quite separate a task from making NixOS runnable on WSL. I'd pretty much do with a ZIP which I'd download from nix site and install for me, not sure I even like the idea of mouseclicking it out of the fancy store instead. Especially if we have to wait for the legal stuff just for the sake of some GUI install scenario.

What's the technical status of running NixOS on WSL? Is it still blocked by the question marks and pipes in the paths? If not, are there any distributions we could try and run right away?

@matthewbauer
Copy link
Member

matthewbauer commented Nov 27, 2018

What's the technical status of running NixOS on WSL? Is it still blocked by the question marks and pipes in the paths? If not, are there any distributions we could try and run right away?

I don't have WSL, but in theory, it should be possible now using the "containerTarball" (nixos-system-x86_64-linux.tar.xz).

You can manipulate this into an install.tar.gz file and get it to run (and make a PR to get it in future release). There will most likely be bugs encountered doing this though. wslu looks to be a good resource to base the install.tar.gz on.

EDIT: It looks like WSL doesn't support systemd! So we will need to do a little more work to get this to work. How would we run the Nix daemon?

Another question that remains to be solved: how can we get Nix to detect that it can run Windows binaries? Nix supports "extra-platforms" so we can reuse that if there were an easy way to run a builder in "windows" mode. Can't find any sort of syscall/API to do this though.

@jacereda
Copy link
Contributor

There's just not systemd without genie. Create init.rc scripts and you'll have the same as having systemd. This would be a bit more challenging for several obvious reasons. But it's doable.

This would be the way to go IMHO, this isn't specific to WSL:

#26067
#26850

@evelant
Copy link
Contributor

evelant commented Sep 13, 2019

I don't pretend to understand enough about linux, wsl, and systemd to know if this is useful, but there's a long thread about systemd on WSL2 here that might have some useful information

microsoft/WSL#994

@WSLUser
Copy link

WSLUser commented Sep 13, 2019

I will note that I've seen plenty of init.rc scripts that including calling systemctl and other systemd functions (we have some for a few Fedora VMs/containers due to things used for managing the hosts.) So the functionality can remain exactly the same except you can add to the scripts other non-systemd stuff so if you don't have systemd, you don't run any of the systemd specific stuff. For redundancies found within a script, those should be abstracted away as much as possible to keep the file size down as well as possibly improve perf from not having to read so many lines. We do want to keep these scripts as small as possible following best coding practices.

@puffnfresh
Copy link
Member

I looked into Genie and figured out how it's running systemd. I then wrote a NixOS module to wrap systemd and systemctl instead:

puffnfresh@08d8c23

It's somewhat working. Sometimes systemd starts up well and you can run systemctl to check on services, etc. It seems like nixos-rebuild switch mostly doesn't work, sadly. Still quite a bit of debugging to do.

@DanielFabian
Copy link
Contributor

Whilst the nixos-rebuild switch is a bit of a shame, I think it's less important on WSL2 as the reboot time is only 1-2 seconds anyway.

@evelant
Copy link
Contributor

evelant commented Apr 7, 2020

Looks like somebody has it working 100% here, but I haven't tried it out yet https://github.com/Trundle/NixOS-WSL

@wmertens
Copy link
Contributor

wmertens commented Apr 7, 2020

Systemd now has the --system flag which lets it run even if it doesn't have PID 1, so maybe all we need to do is set that flag?

@lulcat

This comment has been minimized.

@lulcat

This comment has been minimized.

@wmertens
Copy link
Contributor

@lulcat The init system used to be upstart iirc, feel free to find those commits and propose a maintainable combined system. There's also a lot to read in previous issues on this topic.

The gist of it is that it's hard to create a wrapper around init systems with such diverse capabilities without being very limiting or re-writing systemd capabilities; as such, NixOS modules use only systemd.

@GuillaumeDesforges
Copy link
Contributor

Seems like it works now.
Any news on a possible release on the Microsoft Store ?

@WSLUser
Copy link

WSLUser commented Jun 3, 2020

At the very least, an offline msix could be provided (that's still signed) to make usable outside of Store. The wsl --import option is great but an offline msix would be even greater.

@stale
Copy link

stale bot commented Nov 30, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 30, 2020
@WSLUser
Copy link

WSLUser commented Nov 30, 2020

Not Stale - still not in the Store

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 30, 2020
@hypersw
Copy link
Contributor

hypersw commented Dec 15, 2020

Are there any specific instructions for planting it into the WSL? Preferably, ones which do not involve writing an app in C++ and compiling it with Visual Studio. Everything there sounds not too hard — if you've done it before, and got all the tooling. But for the first time…

If not in the Store, a ready set of the DistroLauncher and install.tar.gz would be nice to have.

Rumors are, you can install an install.tar.gz by placing it alongside an Ubuntu.exe and running, but the part which says "It is expected that /nix/var/nix/profiles/system/activate is run during installation, for example as part of the DistributionInfo::CreateUser function" sounds as if it could be a problem.

Another issue is that you need NixOS to make a tar.gz you need to run NixOS, which in context of our task (running NixOS on Windows NT) sounds close to "unzip.zip".

@scalavision
Copy link
Contributor

scalavision commented Jan 7, 2021

@GuillaumeDesforges or @WSLUser , do you know if anyone actually have tried to get this into Windows Store? Is there a request I could give thumbs up to somewhere? (don't know anything about how windows store works) ..

@GuillaumeDesforges
Copy link
Contributor

@GuillaumeDesforges or @WSLUser , do you know if anyone actually have tried to get this into Windows Store? Is there a request I could give thumbs up to somewhere? (don't know anything about how windows store works) ..

From @ghuntley (#30391 (comment))

In private discussions with Microsoft about getting NixOS into the Microsoft App Store. Have been a little overwhelmed recently but it's high on my todo list. Microsoft are waiting on me.

Other than that idk.

It would help to have someone who knows the procedure to be accountable (maybe a strong word but I don't know another) on this (both follow technical issues and WS request)

@pecigonzalo
Copy link

Seems like it works now.
Any news on a possible release on the Microsoft Store ?

It would be great to have some manual steps to get it running as well. Is https://github.com/Trundle/NixOS-WSL the recommended way for example?

@JamieMagee JamieMagee mentioned this issue May 19, 2021
10 tasks
@veprbl veprbl removed this from the 19.09 milestone May 31, 2021
@allumik
Copy link

allumik commented Jan 19, 2022

Is following the Trundle's repo still the best way to generate latest NixOS for WSL? Or are some forks or other repos that have 20.09+ images available? Possibly with WSLg, wslu support etc.

@alexvorobiev
Copy link
Contributor

I commented in that repo that distrod claims to help with the systemd issue. Distrod relies on https://linuxcontainers.org which doesn't have anything for NixOS. Would it be difficult to create NixOS images for LXC/LXD and linuxcontainers.org so that distrod could be leveraged?

@asbachb
Copy link
Contributor

asbachb commented Jan 19, 2022 via email

@sielicki
Copy link
Contributor

The nixos-wsl repo under nix-community is under a new maintainer and getting a lot of much-needed attention. There’s a good chance that we can get this done, soon.

@sielicki
Copy link
Contributor

nix-community/NixOS-WSL#63

Please close this and redirect discussion here.

@omasanori
Copy link
Contributor

Closing as requested. Feel free to reopen if it is not appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: windows Running, or buiding, packages on Windows
Projects
None yet
Development

No branches or pull requests