Compare commits

...

20 Commits

Author SHA1 Message Date
24b6d1f115 replace unzip with builtin Expand-Archive tool 2024-11-24 23:41:49 +01:00
52e9367b04 optionally skip config after installation 2024-11-24 23:27:00 +01:00
8ed8d2d411 allow bypassing additional installation steps 2024-11-24 22:59:51 +01:00
eaf1e8e9f3 using push/pop location instead to accommodate for powershell v5 2024-11-24 22:55:12 +01:00
8c6dcd4590 bugfix: set location to dotfiles repo for admin processes 2024-11-24 22:39:20 +01:00
ff07ff7d17 bugfix: remove escaped quotes 2024-11-24 22:32:47 +01:00
7f7fc0a8ba bugfix: fix filepath when calling from local dir 2024-11-24 22:12:46 +01:00
c5c7703e00 Revert "bugfix: fix filepath when calling from local dir"
This reverts commit 1e19a5e1cf.
2024-11-24 22:12:09 +01:00
df70d04ddc bugfix: set bypass policy for admin processes 2024-11-24 21:51:25 +01:00
eed5118341 cleanup: improved minor quality and descriptions 2024-11-24 21:42:00 +01:00
5014da3a46 bugfix: install wsl and windows features as administrator 2024-11-24 21:40:51 +01:00
509ebf7437 bugfix: wait for admin installation process to complete 2024-11-24 21:35:50 +01:00
cb66813a8b bugfix: typos in function names (switcheroo) 2024-11-24 21:32:45 +01:00
9cc28a14e1 bugfix: call 'InstallWinget' with admin privileges 2024-11-24 21:29:15 +01:00
1e19a5e1cf bugfix: fix filepath when calling from local dir 2024-11-24 21:28:57 +01:00
e2edd0122e replace concrete commands with reference to installation modules 2024-11-24 21:17:39 +01:00
ec067674d3 add wsl/apt installation module 2024-11-24 21:15:14 +01:00
d95ba9823d add chocolatey installation module 2024-11-24 21:14:55 +01:00
3a849a448f add winget installation module 2024-11-24 21:14:46 +01:00
5090a04e95 rename function parameter for naming consistency 2024-11-24 21:12:23 +01:00
9 changed files with 177 additions and 49 deletions

View File

@ -33,31 +33,8 @@ These tools include the following for Windows Installs (Recommended using [Choco
- [Python](https://www.python.org/)
- [Composer](https://getcomposer.org/)
<details><summary>Windows Subsystem for Linux</summary>
```bash
sudo apt update
curl -fsSL https://deb.nodesource.com/setup_lts.x -o nodesource_setup.sh
sudo -E bash nodesource_setup.sh
sudo add-apt-repository ppa:neovim-ppa/unstable -y
sudo apt install make gcc ripgrep unzip git xclip neovim nodejs python3-venv
curl https://sh.rustup.rs -sSf | sh
curl -LO https://go.dev/dl/go1.23.2.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.23.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
```
</details>
<details><summary>Winget and Chocolatey</summary>
```pwsh
winget install chocolatey.chocolatey Neovide.Neovide Alacritty.Alacritty Git.Git GoLang.Go Microsoft.DotNet.SDK.8 OpenJS.NodeJS.LTS Python.Python.3.12 Rustlang.Rustup
choco install neovim ripgrep curl wget fd unzip gzip mingw make
```
</details>
> **NOTE**
> For more information, simply see all [util/](./util) installation modules.
## Installation

View File

@ -1,4 +1,19 @@
Import-Module ./util/chocolatey.psm1
Import-Module ./util/windows.psm1
Import-Module ./util/winget.psm1
Import-Module ./util/wsl.psm1
# (Optionally) Install required Software
WingetInstall
ChocolateyInstall
WSLInstall
Write-Host "Installation Steps complete!" -ForegroundColor Cyan
$continue = Read-Host "Continue with configuration? [Y/n]:"
if ($continue.ToLower() -eq 'n')
{ return
}
# Define paths for tools and configurations
@ -15,7 +30,7 @@ ReadyDotfilesRepo -cwd $currentDir -url $repoUrl -destination $dotfilesRepo
# Setting up Alacritty Configuration
Write-Host "Setting up Alacritty configuration..." -ForegroundColor Cyan
ProcessUrlFiles -sourceDir "$dotfilesRepo\alacritty" -destinationDir $alacrittyConfigDir
ProcessUrlFiles -source "$dotfilesRepo\alacritty" -destination $alacrittyConfigDir
# Copy the main Alacritty configuration file
CopyFileWithPrompt "$dotfilesRepo\alacritty\alacritty.toml" "$alacrittyConfigDir\alacritty.toml"
@ -24,15 +39,9 @@ CopyFileWithPrompt "$dotfilesRepo\alacritty\alacritty.toml" "$alacrittyConfigDir
Write-Host "Setting up Neovim configuration..." -ForegroundColor Cyan
$ubuntu = wsl.exe -l --all | Where-Object { $_.Replace("`0", "") -match '^Ubuntu' }
if ($null -eq $ubuntu)
{ ProcessUrlFiles -sourceDir "$dotfilesRepo\nvim" -destinationDir "$env:LOCALAPPDATA"
{ 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
@ -47,7 +56,7 @@ Write-Host "============================================" -ForegroundColor DarkG
# Installing Nerd Fonts
Write-Host "Installing Nerd Fonts..." -ForegroundColor Cyan
ProcessUrlFiles -sourceDir "$dotfilesRepo\nerd-fonts" -fileExt ".zip"
ProcessUrlFiles -source "$dotfilesRepo\nerd-fonts" -fileExt ".zip"
UnzipAndInstall -source "$dotfilesRepo\nerd-fonts"
# Final message

10
util/chocolatey.list Normal file
View File

@ -0,0 +1,10 @@
neovim
ripgrep
wget
curl
fd
unzip
gzip
mingw
make
composer

17
util/chocolatey.psm1 Normal file
View File

@ -0,0 +1,17 @@
function InstallPackages
{
choco.exe install (Get-Content ./util/chocolatey.list)
}
function ChocolateyInstall
{
$install = Read-Host "Install Chocolatey Packages now? [Y/n]"
if ($install.ToLower() -eq 'n')
{ return
}
# Start admin process, import this script, run 'InstallPackages' function
Start-Process powershell.exe -Verb RunAs -Wait `
-ArgumentList "-ExecutionPolicy", "Bypass", `
"-C", "cd $pwd; ipmo ./util/chocolatey.psm1; InstallPackages"
}

View File

@ -76,34 +76,35 @@ function CopyFileWithPrompt
function ProcessUrlFiles
{
param (
[string]$sourceDir,
[Parameter(Mandatory=$false)][string]$destinationDir,
[string]$source,
[Parameter(Mandatory=$false)][string]$destination,
[Parameter(Mandatory=$false)][string]$fileExt
)
# Ensure the destination directory exists
if ($destinationDir -and (-not (Test-Path $destinationDir)))
if ($destination -and (-not (Test-Path $destination)))
{
Write-Host "Creating destination directory $destinationDir..." -ForegroundColor Cyan
New-Item -ItemType Directory -Path $destinationDir | Out-Null
Write-Host "Creating destination directory $destination..." -ForegroundColor Cyan
New-Item -ItemType Directory -Path $destination | Out-Null
}
# Create temporary directory for curl
$appname = $sourceDir.Split('\')[-1]
$appname = $source.Split('\')[-1]
$tmpApp = "$env:TMP\$appname-config"
if (-not (Test-Path $tmpApp))
{ New-Item -ItemType Directory -Path $tmpApp | Out-Null
}
Push-Location
Set-Location $tmpApp
# Find all .url files in the source directory
$urlFiles = Get-ChildItem -Path $sourceDir -Filter '*.url'
$urlFiles = Get-ChildItem -Path $source -Filter '*.url'
foreach ($file in $urlFiles)
{
$url = Get-Content $file.FullName
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
$destinationPath = "$destinationDir\$fileName"
$destinationPath = "$destination\$fileName"
if (-not ($url -match 'git@|https://.*\.git'))
{
@ -115,11 +116,11 @@ function ProcessUrlFiles
$extension = $fileExt
$url += $fileExt
}
$destinationPath = "$destinationDir\$fileName$extension"
$destinationPath = "$destination\$fileName$extension"
# Respond only if destination is provided
$conditional = " to $destinationPath"
if (-not $destinationDir)
if (-not $destination)
{ $conditional = ''
}
@ -128,14 +129,14 @@ function ProcessUrlFiles
$tmpDestination = "$tmpApp\$fileName$extension"
# Copy only if destination is provided
if ($destinationDir)
if ($destination)
{ CopyFileWithPrompt $tmpDestination $destinationPath
}
continue
}
# Use $tmpApp as destination in case of git repo
if (-not $destinationDir)
if (-not $destination)
{ $destinationPath = "$tmpApp\$fileName"
}
@ -150,7 +151,7 @@ function ProcessUrlFiles
Write-Host "Cloning $fileName from $url to $destinationPath..." -ForegroundColor Cyan
git clone $url $destinationPath
}
Set-Location -
Pop-Location
}
# Function to expand zip archives and copy to destination paths
@ -174,7 +175,7 @@ function UnzipAndInstall
{
$fileName = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
Write-Host "Extracting archive $tmpApp\$fileName.zip to $tmpApp\$fileName\..." -ForegroundColor Cyan
unzip -o "$tmpApp\$fileName.zip" -d "$tmpApp\$fileName" | Out-Null
Expand-Archive "$tmpApp\$fileName.zip" -DestinationPath "$tmpApp\$fileName" | Out-Null
Write-Host "Installing fonts from $tmpApp\$fileName\ for current user..." -ForegroundColor Cyan
Copy-Item -Path "$tmpApp\$fileName\*" -Destination "$env:LOCALAPPDATA\Microsoft\Windows\Fonts\" -Force -ErrorAction SilentlyContinue

11
util/winget.list Normal file
View File

@ -0,0 +1,11 @@
Git.Git
Microsoft.OpenJDK.21
Alacritty.Alacritty
OpenJS.NodeJS.LTS
Chocolatey.Chocolatey
Microsoft.DotNet.SDK.8
Microsoft.PowerShell
GoLang.Go
Python.Python.3.12
Rustlang.Rustup
rjpcomputing.luaforwindows

29
util/winget.psm1 Normal file
View File

@ -0,0 +1,29 @@
function InstallWinget
{
# Reference: https://learn.microsoft.com/en-us/windows/package-manager/winget/#install-winget-on-windows-sandbox
$progressPreference = 'silentlyContinue'
Write-Host "Installing WinGet PowerShell module from PSGallery..."
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Module -Name Microsoft.WinGet.Client -Force -Repository PSGallery | Out-Null
Write-Host "Using Repair-WinGetPackageManager cmdlet to bootstrap WinGet..."
Repair-WinGetPackageManager
}
function WingetInstall
{
$update = Read-Host "Install/Update WinGet now? [Y/n]"
if ($update.ToLower() -ne 'n')
{
# Start admin process, import this script, run 'InstallPackages' function
Start-Process powershell.exe -Verb RunAs -Wait `
-ArgumentList "-ExecutionPolicy", "Bypass", `
"-C", "cd $pwd; ipmo ./util/winget.psm1; InstallWinget"
}
$install = Read-Host "Install WinGet Packages now? [Y/n]"
if ($install.ToLower() -eq 'n')
{ return
}
winget.exe install -s winget --accept-source-agreements (Get-Content ./util/winget.list)
}

14
util/wsl.list Normal file
View 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

60
util/wsl.psm1 Normal file
View File

@ -0,0 +1,60 @@
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
}
$update = Read-Host "Install/Update WSL2 now? [Y/n]"
if ($update.ToLower() -ne 'n')
{
# Start admin process, import this script, run 'InstallPackages' function
Start-Process powershell.exe -Verb RunAs -Wait `
-ArgumentList "-ExecutionPolicy", "Bypass", `
"-C", "cd $pwd; ipmo ./util/wsl.psm1; InstallWSL"
}
$install = Read-Host "Install WSL Distribution now? [Y/n]"
if ($install.ToLower() -eq 'n')
{ return
}
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
Push-Location
Set-Location "$env:TMP\nvim-config"
Write-Host "Copying (forcably) configuration to WSL..." -ForegroundColor Yellow
wsl.exe cp -rf . ~/.config/ 2>$null | Out-Null
Pop-Location
}