NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.05k stars 14.09k forks source link

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

Closed ThomasMader closed 2 years ago

ThomasMader commented 7 years ago

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. (https://github.com/Microsoft/BashOnWindows/issues/2253)

Are there any showstoppers?

zimbatm commented 5 years ago

Just as a recap:

I just wanted to communicate clearly that it's not just a small patch away.

From there, there are two routes possible:

  1. The short and hacky route. It's possible to override the nixos modules to make it mostly work. This is what arion does for example. The main downside is that things will never be 100% compatible and prone to break during channel updates.
  2. The proper route. This would require to go an split NixOS up properly. Define a common interface for cross-init systems. Mark modules that only works on "NixOS Linux" (vs "NixOS WSL2").

IMO option (2) is much better to avoid giving a false expectations. It's definitely a project but it's not completely insurmountable to do.

WSLUser commented 5 years ago

You don't get to choose the linux kernel and there is no init system

You actually can import your own kernel for the past 2 or 3 Insider builds. There's a few other things as well. See the blogs. And there is an init system. 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.

WSLUser commented 5 years ago

Also, NX-OS would still have to work on WSL1 as that is the default even after enabling WSL2. But it's still the same as my last comment.

jacereda commented 5 years ago

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:

https://github.com/NixOS/nixpkgs/issues/26067 https://github.com/NixOS/nixpkgs/issues/26850

evelant commented 5 years ago

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

https://github.com/microsoft/WSL/issues/994

WSLUser commented 5 years ago

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 commented 4 years ago

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

https://github.com/puffnfresh/nixpkgs/commit/08d8c23eebb0a5ab90db94a05e297630227cb232

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 commented 4 years ago

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 commented 4 years ago

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

wmertens commented 4 years ago

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 commented 4 years ago

lol? I run a non systemd distro, and I have no issues with running systemd inside containers (non pid 1) fully non degraded, so didn't even systemd needed such flag? Out of curiousity, why on EARTH would anyone want / need to run linux on windows and not vice versa? Is it basically an update to cygwin or so? 2020? ye, 20 year late MS.. 90s os :) what is WSL?

lulcat commented 4 years ago

OH.. NixOS as I understood it was meant to be so 'smart about running several versions' but it can't even handle different inits? I understand one can blame systemd for that, but it's usually easier to run all good citizens together, as options, and leave the one bad one out. Still, I guess NixOS , despite having grown, isn't really all that then.

wmertens commented 4 years ago

@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 commented 4 years ago

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

WSLUser commented 4 years ago

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[bot] commented 3 years ago

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

WSLUser commented 3 years ago

Not Stale - still not in the Store

hypersw commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

@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 (https://github.com/NixOS/nixpkgs/issues/30391#issuecomment-411413299)

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 commented 3 years ago

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?

allumik commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

I'm running NixOS on lxd, but tbh it's not straight forward and you need to configure quite a lot in os level. There's also https://github.com/nix-community/nixos-generators which is able to generate LCD images.

19 Jan 2022 19:29:32 Alex Vorobiev @.***>:

I commented[https://github.com/Trundle/NixOS-WSL/issues/49#issue-1060671729] in that repo that distrod[https://github.com/nullpo-head/wsl-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?

— Reply to this email directly, view it on GitHub[https://github.com/NixOS/nixpkgs/issues/30391#issuecomment-1016750091], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AALKAEDI6ZDLGPL46XSEZ5DUW37IZANCNFSM4D7CYYCQ]. Triage notifications on the go with GitHub Mobile for iOS[https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675] or Android[https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub]. You are receiving this because you are subscribed to this thread. [data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAYAAADjVADoAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAAnSURBVHic7cEBDQAAAMKg909tDwcUAAAAAAAAAAAAAAAAAAAAAPBjRFIAASHKmKkAAAAASUVORK5CYII=###24x24:true###][Tracking image][https://github.com/notifications/beacon/AALKAEE5NVSY4ERUC2A52Z3UW37IZA5CNFSM4D7CYYC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHSNGACY.gif]

sielicki commented 2 years ago

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 commented 2 years ago

https://github.com/nix-community/NixOS-WSL/issues/63

Please close this and redirect discussion here.

omasanori commented 2 years ago

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