WSL: Difference between revisions

Onny (talk | contribs)
Further details on WSL2 installation
Phobos (talk | contribs)
m Updated intructions
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Notes on running NixOS on the Windows Subsystem for Linux (WSL, WSL2)
Notes on running NixOS on the Windows Subsystem for Linux (WSL, WSL2).


== Setup ==
== Setup ==
Line 12: Line 12:
Sometimes you'll have to install WSL2 manually by [https://github.com/microsoft/WSL/releases downloading the msi-installation package].
Sometimes you'll have to install WSL2 manually by [https://github.com/microsoft/WSL/releases downloading the msi-installation package].


NixOS is [https://github.com/microsoft/WSL/issues/11206 not yet packaged] as a official WSL distribution or on the Microsoft store. Download the latest release of <code>nixos-wsl.tar.gz</code> from the [https://github.com/nix-community/NixOS-WSL/releases NixOS-WSL Github page].
NixOS is [https://github.com/microsoft/WSL/issues/11206 not yet packaged] as a official WSL distribution or on the Microsoft store. Download the latest release of <code>nixos.wsl</code> from the [https://github.com/nix-community/NixOS-WSL/releases NixOS-WSL Github page].


Import the WSL container using PowerShell
Double-click the file you just downloaded (requires WSL >= 2.4.4).
 
<syntaxhighlight lang="powershell">
wsl --import NixOS .\NixOS\ nixos-wsl.tar.gz --version 2
</syntaxhighlight>


== Usage ==
== Usage ==


Start it with PowerShell
Start it with PowerShellː


<syntaxhighlight lang="powershell">
<syntaxhighlight lang="powershell">
Line 32: Line 28:
=== Run container on startup ===
=== Run container on startup ===


To run the distro <code>NixOS</code> on Windows startup or user login in the background, proceed with following commands in PowerShell
To run the distro <code>NixOS</code> on Windows startup or user login in the background, use these commands in PowerShellː


<syntaxhighlight lang="powershell">
<syntaxhighlight lang="powershell">
Line 39: Line 35:
</syntaxhighlight>
</syntaxhighlight>


Inside the script we define <code>NixOS</code> as the distribution name, as imported in the setup step above
Inside the script we define <code>NixOS</code> as the distribution name, as imported in the setup step above.


{{file|$HOME\run_wsl2_at_startup.vbs|vbscript|<nowiki>
{{file|$HOME\run_wsl2_at_startup.vbs|vbscript|<nowiki>
Line 46: Line 42:
</nowiki>}}
</nowiki>}}


Execute following command to open the task planer
Open the task schedulerː


<syntaxhighlight lang="powershell">
<syntaxhighlight lang="powershell">
Line 52: Line 48:
</syntaxhighlight>
</syntaxhighlight>


Click on <code>Create task</code> on the right pane, set name to <code>WSL</code>. On the tab "Triggers" click on "New ..." and select run task on user login in the dropdown menu. On the tab "Action" click on "New ..." and insert as command: <code>%USERPROFILE%\run_wsl2_at_startup.vbs</code>
Click on <code>Create task</code> on the right pane, set name to <code>WSL</code>. On the tab "Triggers" click on "New ..." and select "run task on user login" in the dropdown menu. On the tab "Action" click on "New ..." and insert as command: <code>%USERPROFILE%\run_wsl2_at_startup.vbs</code>
[[Category:Container]]