2024-11-24 20:15:14 +00:00
|
|
|
function InstallWSL
|
|
|
|
{
|
2024-11-25 11:00:30 +00:00
|
|
|
Write-Host "Enabling and downloading required Windows Features..."
|
|
|
|
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -All -NoRestart | Out-Null
|
|
|
|
Enable-WindowsOptionalFeature -Online -FeatureName "VirtualMachinePlatform" -All -NoRestart | Out-Null
|
|
|
|
Write-Host "Installing WSL2..."
|
2024-11-25 10:54:14 +00:00
|
|
|
wsl.exe --install --no-distribution
|
2024-11-24 20:15:14 +00:00
|
|
|
wsl.exe --set-default-version 2
|
|
|
|
}
|
|
|
|
|
|
|
|
function WSLInstall
|
|
|
|
{
|
|
|
|
# Skip if any WSL2 installations can be found
|
|
|
|
$installations = wsl.exe -l -v
|
|
|
|
$filtered = $installations | Where-Object { $_.Replace("`0", '') -match '^.{2}Ubuntu' }
|
|
|
|
$versions = $filtered | ForEach-Object { $_.Substring($_.LastIndexOf(' ') + 1) }
|
|
|
|
if ($null -ne $versions -and $versions.Contains('2'))
|
|
|
|
{ return
|
|
|
|
}
|
|
|
|
|
2024-11-24 21:59:51 +00:00
|
|
|
$update = Read-Host "Install/Update WSL2 now? [Y/n]"
|
|
|
|
if ($update.ToLower() -ne 'n')
|
2024-11-24 20:40:51 +00:00
|
|
|
{
|
|
|
|
# Start admin process, import this script, run 'InstallPackages' function
|
|
|
|
Start-Process powershell.exe -Verb RunAs -Wait `
|
2024-11-24 20:51:25 +00:00
|
|
|
-ArgumentList "-ExecutionPolicy", "Bypass", `
|
2024-11-24 21:39:20 +00:00
|
|
|
"-C", "cd $pwd; ipmo ./util/wsl.psm1; InstallWSL"
|
2024-11-24 20:15:14 +00:00
|
|
|
}
|
2024-11-24 21:59:51 +00:00
|
|
|
|
|
|
|
$install = Read-Host "Install WSL Distribution now? [Y/n]"
|
|
|
|
if ($install.ToLower() -eq 'n')
|
|
|
|
{ return
|
|
|
|
}
|
|
|
|
|
2024-11-24 20:15:14 +00:00
|
|
|
wsl.exe --install -d Ubuntu
|
|
|
|
|
|
|
|
# Add newly created user to sudoers group
|
2024-11-25 11:18:39 +00:00
|
|
|
$user = wsl.exe cut "-d:" "-f1" /etc/passwd | Select-Object -Last 1
|
|
|
|
wsl.exe -u root echo "$user ALL=(ALL) NOPASSWD:ALL" ">>" "/etc/sudoers.d/$user"
|
2024-11-24 20:15:14 +00:00
|
|
|
|
|
|
|
# Update packages and install from list
|
|
|
|
wsl.exe sudo apt update "&&" sudo apt upgrade "-y"
|
|
|
|
wsl.exe sudo apt install "-y" (Get-Content ./util/wsl.list)
|
|
|
|
}
|
|
|
|
|
|
|
|
function InstallWSLNeovim
|
|
|
|
{
|
|
|
|
param (
|
|
|
|
[string]$source
|
|
|
|
)
|
|
|
|
|
2024-11-25 14:06:01 +00:00
|
|
|
Import-Module ./util/windows.psm1
|
2024-11-24 20:15:14 +00:00
|
|
|
|
2024-11-24 21:55:12 +00:00
|
|
|
Push-Location
|
2024-11-25 13:25:44 +00:00
|
|
|
ProcessUrlFiles -source $source
|
2024-11-24 20:15:14 +00:00
|
|
|
Set-Location "$env:TMP\nvim-config"
|
2024-11-25 13:25:44 +00:00
|
|
|
|
2024-11-24 20:15:14 +00:00
|
|
|
Write-Host "Copying (forcably) configuration to WSL..." -ForegroundColor Yellow
|
|
|
|
wsl.exe cp -rf . ~/.config/ 2>$null | Out-Null
|
2024-11-24 21:55:12 +00:00
|
|
|
Pop-Location
|
2024-11-24 20:15:14 +00:00
|
|
|
}
|