WSL: Difference between revisions
imported>Onny Add note on update WSL |
imported>Onny Run container on startup |
||
Line 24: | Line 24: | ||
wsl -d NixOS | wsl -d NixOS | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Tips and tricks == | |||
== 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 | |||
<syntaxhighlight lang="bash"> | |||
echo "" > $HOME\run_wsl2_at_startup.vbs | |||
notepad $HOME\run_wsl2_at_startup.vbs | |||
</syntaxhighlight> | |||
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|vbs|<nowiki> | |||
set object = createobject("wscript.shell") | |||
object.run "wsl.exe --distribution NixOS", 0 | |||
</nowiki>}} | |||
Execute following command to open the task planer | |||
<syntaxhighlight lang="bash"> | |||
taskschd.msc | |||
</syntaxhighlight> | |||
Click on <code>New 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. On the tab "Action" click on "New ..." and insert as command: <code>%USERPROFILE%\run_wsl2_at_startup.vbs</code> |
Revision as of 14:31, 24 January 2024
Notes on running NixOS on the Windows Subsystem for Linux (WSL, WSL2)
Setup
Ensure that WSL is installed and up to date
wsl --update
Download the latest release of nixos-wsl.tar.gz
from the NixOS-WSL Github page.
Import the WSL container using PowerShell
wsl --import NixOS .\NixOS\ nixos-wsl.tar.gz --version 2
Usage
Start it with PowerShell
wsl -d NixOS
Tips and tricks
Run container on startup
To run the distro NixOS
on Windows startup or user login in the background, proceed with following commands in PowerShell
echo "" > $HOME\run_wsl2_at_startup.vbs
notepad $HOME\run_wsl2_at_startup.vbs
Inside the script we define NixOS
as the distribution name, as imported in the setup step above
$HOME\run_wsl2_at_startup.vbs
set object = createobject("wscript.shell")
object.run "wsl.exe --distribution NixOS", 0
Execute following command to open the task planer
taskschd.msc
Click on New task
on the right pane, set name to WSL
. On the tab "Triggers" click on "New ..." and select run task on user login. On the tab "Action" click on "New ..." and insert as command: %USERPROFILE%\run_wsl2_at_startup.vbs