Important
Run the following commands from an admin shell:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -All
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -All
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
Run the following command from an admin shell:
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Windows-Subsystem-Linux /norestart
DISM /Online /Enable-Feature /All /FeatureName:VirtualMachinePlatform /norestart
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V /norestart
Important
Run the following command from a non-admin shell:
wsl --install
Important
Run the following command from a non-admin shell:
wsl --update --web-download
To enter the WSL environment simply execute:
wsl
This will launch the default linux OS.
wsl --install
wsl --update --web-download
If you run wsl
and nothing happens (no errors reported, but WSL does not launch). Then run the above commands again.
- First, download the latest release.
- Import NixOS-WSL (run these commands in the same folder where the release
nixos-wsl.tar.gz
was downloaded): Using PowerShell:
wsl --import NixOS $env:USERPROFILE\NixOS\ nixos-wsl.tar.gz
Using Command Prompt:
wsl --import NixOS %USERPROFILE%\NixOS\ nixos-wsl.tar.gz
- Enter the NixOS environment
wsl -d NixOS
Important
4. After the initial installation, you need to update your channels once, to be able to use nixos-rebuild
:
sudo nix-channel --update
To optionally set NixOS as the default for WSL:
wsl -s NixOS
This configuration sets wsl.defaultUser
.
Follow these instructions to make sure, the change gets applied correctly:
- Apply the configuration:
sudo nixos-rebuild boot --flake .#ghost
Caution
Do not use nixos-rebuild switch
! It may lead to the new user account being misconfigured.
- Exit the WSL shell and stop your NixOS distro:
wsl -t NixOS
. - Start a shell inside NixOS and immediately exit it to apply the new generation:
wsl -d NixOS --user root exit
- Stop the distro again:
wsl -t NixOS
- Open a WSL shell. Your new username should be applied now!