mirror of
https://github.com/Baipyrus/dotfiles.git
synced 2024-12-26 03:11:45 +00:00
add wsl/apt installation module
This commit is contained in:
parent
d95ba9823d
commit
ec067674d3
@ -1,11 +1,13 @@
|
||||
Import-Module ./util/chocolatey.psm1
|
||||
Import-Module ./util/windows.psm1
|
||||
Import-Module ./util/winget.psm1
|
||||
Import-Module ./util/wsl.psm1
|
||||
|
||||
|
||||
# (Optionally) Install required Software
|
||||
InstallWinget
|
||||
InstallChocolatey
|
||||
InstallWSL
|
||||
|
||||
# Define paths for tools and configurations
|
||||
$dotfilesRepo = "$env:TMP\dotfiles"
|
||||
@ -32,13 +34,7 @@ $ubuntu = wsl.exe -l --all | Where-Object { $_.Replace("`0", "") -match '^Ubuntu
|
||||
if ($null -eq $ubuntu)
|
||||
{ ProcessUrlFiles -source "$dotfilesRepo\nvim" -destination "$env:LOCALAPPDATA"
|
||||
} else
|
||||
{
|
||||
# TODO: Expand into generic WSL setup while installing required dev tools
|
||||
ProcessUrlFiles -sourceDir "$dotfilesRepo\nvim"
|
||||
Set-Location "$env:TMP\nvim-config"
|
||||
Write-Host "Copying (forcably) configuration to WSL..." -ForegroundColor Yellow
|
||||
wsl.exe cp -rf . ~/.config/ 2>$null | Out-Null
|
||||
Set-Location -
|
||||
{ InstallWSLNeovim -source "$dotfilesRepo\nvim"
|
||||
}
|
||||
|
||||
# Setting up PowerShell Profile
|
||||
|
14
util/wsl.list
Normal file
14
util/wsl.list
Normal file
@ -0,0 +1,14 @@
|
||||
make
|
||||
gcc
|
||||
ripgrep
|
||||
unzip
|
||||
git
|
||||
xclip
|
||||
python3
|
||||
python3-venv
|
||||
composer
|
||||
luarocks
|
||||
fd-find
|
||||
python3-pip
|
||||
python3-pynvim
|
||||
openjdk-21-jdk-headless
|
48
util/wsl.psm1
Normal file
48
util/wsl.psm1
Normal file
@ -0,0 +1,48 @@
|
||||
function InstallWSL
|
||||
{
|
||||
# Reference: https://learn.microsoft.com/en-us/windows/wsl/install-manual
|
||||
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
|
||||
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
|
||||
wsl.exe --update
|
||||
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
|
||||
}
|
||||
|
||||
$install = Read-Host "Install WSL2 now? [Y/n]"
|
||||
if ($install.ToLower() -ne 'n')
|
||||
{ InstallWSL
|
||||
}
|
||||
wsl.exe --install -d Ubuntu
|
||||
|
||||
# Add newly created user to sudoers group
|
||||
$user = wsl.exe cut "-d:" "-f1" /etc/passwd
|
||||
wsl.exe -u root echo "echo ""$user ALL=(ALL) NOPASSWD:ALL"" >> /etc/sudoers.d/$user"
|
||||
|
||||
# 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
|
||||
)
|
||||
|
||||
Import-Module ./windows.psm1
|
||||
|
||||
ProcessUrlFiles -sourceDir $source
|
||||
Set-Location "$env:TMP\nvim-config"
|
||||
Write-Host "Copying (forcably) configuration to WSL..." -ForegroundColor Yellow
|
||||
wsl.exe cp -rf . ~/.config/ 2>$null | Out-Null
|
||||
Set-Location -
|
||||
}
|
Loading…
Reference in New Issue
Block a user