From 3a849a448fa151edd5b0bdd7d139370e975d7400 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sun, 24 Nov 2024 21:14:10 +0100 Subject: [PATCH] add winget installation module --- install_windows.ps1 | 4 ++++ util/winget.list | 11 +++++++++++ util/winget.psm1 | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 util/winget.list create mode 100644 util/winget.psm1 diff --git a/install_windows.ps1 b/install_windows.ps1 index 3ec15c7..2200b8e 100644 --- a/install_windows.ps1 +++ b/install_windows.ps1 @@ -1,6 +1,10 @@ Import-Module ./util/windows.psm1 +Import-Module ./util/winget.psm1 +# (Optionally) Install required Software +InstallWinget + # Define paths for tools and configurations $dotfilesRepo = "$env:TMP\dotfiles" $alacrittyConfigDir = "$env:APPDATA\alacritty" diff --git a/util/winget.list b/util/winget.list new file mode 100644 index 0000000..f398c56 --- /dev/null +++ b/util/winget.list @@ -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 diff --git a/util/winget.psm1 b/util/winget.psm1 new file mode 100644 index 0000000..a612b54 --- /dev/null +++ b/util/winget.psm1 @@ -0,0 +1,20 @@ +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 +{ + $install = Read-Host "Install WinGet now? [Y/n]" + if ($install.ToLower() -ne 'n') + { InstallWinget + } + + winget.exe install -s winget --accept-source-agreements (Get-Content ./util/winget.list) +}