Created
October 6, 2023 07:32
-
-
Save netbrain/a1093ff0d882b95c8fb62787c1c53227 to your computer and use it in GitHub Desktop.
nixos wsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Function to download the tar file | |
| function Download-NixOS { | |
| $url = "https://github.com/nix-community/nixos-wsl/releases/latest/download/nixos-wsl.tar.gz" | |
| $output = "$env:TEMP\nixos-wsl.tar.gz" | |
| Invoke-WebRequest -Uri $url -OutFile $output | |
| return $output | |
| } | |
| # Function to check if WSL is installed and install if it's not | |
| function Install-WSL { | |
| $wslInstalled = Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux | |
| if ($wslInstalled.State -ne 'Enabled') { | |
| Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -All -NoRestart | |
| } | |
| } | |
| # Function to import into WSL | |
| function Import-WSL ($tarPath) { | |
| wsl --import NixOS .\NixOS\ $tarPath --version 2 | |
| } | |
| # Main execution | |
| $tarPath = Download-NixOS | |
| Install-WSL | |
| Import-WSL -tarPath $tarPath |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After install of nixos: