commit b2d9581c25d4e77c4ccadecb6a0611780fa8f061 Author: Joakim Hulthe Date: Fri Jun 5 13:31:10 2026 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dace708 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.vagrant diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..aca0cbe --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,116 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "gusztavvargadr/windows-11" + config.vm.box_version = "2511.0.0" + + config.vm.provider :libvirt do |libvirt| + libvirt.cpus = 8 + libvirt.memory = 8192 + + # Setup virtio+spice video with opengl acceleration + libvirt.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio' + libvirt.graphics_type = "spice" + libvirt.video_type = "virtio" + libvirt.video_accel3d = true + end + + # use NFS for file syncing. requires nfs-utils + # config.vm.synced_folder ".", "/vagrant", type: "nfs" + config.vm.synced_folder ".", "/vagrant", disabled: true + + # TODO: zed + # https://github.com/zed-industries/zed/releases/download/v0.216.0/Zed-x86_64.exe + + # TODO: configure WFP to *always* allow RDP and SSH from the host + config.vm.provision "shell", path: "scripts/enable-rdp.ps1" + + # TODO: this will hang provisioning because Set-WinUserLanguageList always asks for confirmation, ignoring `-Confirm` & `-Force` + # config.vm.provision "shell", path: "scripts/add-swedish-keyboard.ps1" + + # config.vm.provision "shell", path: "scripts/win11-debloat.ps1" # TODO: this hangs + config.vm.provision "shell", path: "scripts/theme.ps1", args: "-Mode dark" + config.vm.provision "shell", path: "scripts/restart-explorer.ps1" # for the theme to take effect + config.vm.provision "shell", path: "scripts/install-chocolatey.ps1" # Run the external script to install Chocolatey + config.vm.provision "shell", path: "scripts/choco-install.ps1" # use choco to install all the things + config.vm.provision "shell", path: "scripts/get-mullvad-loader.ps1" # use choco to install all the things + + # TODO: set "Terminal" as default over cmd + # TODO: set nu as default shell + config.vm.provision "shell", path: "scripts/setup-nu.ps1" # configue nu env + # config.vm.provision "shell", inline: "echo Hello There" + + # ------ examples below ------- + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # NOTE: This will enable public access to the opened port + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine and only allow access + # via 127.0.0.1 to disable public access + # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Disable the default share of the current code directory. Doing this + # provides improved isolation between the vagrant box and your host + # by making sure your Vagrantfile isn't accessible to the vagrant box. + # If you use this you may want to enable additional shared subfolders as + # shown above. + # config.vm.synced_folder ".", "/vagrant", disabled: true + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Enable provisioning with a shell script. Additional provisioners such as + # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the + # documentation for more information about their specific syntax and use. + # config.vm.provision "shell", inline: <<-SHELL + # apt-get update + # apt-get install -y apache2 + # SHELL +end diff --git a/rdp.nu b/rdp.nu new file mode 100755 index 0000000..0377fa5 --- /dev/null +++ b/rdp.nu @@ -0,0 +1,21 @@ +#!/usr/bin/env nu + +# Connect with the VM over RDP. +# +# Requires XWayland or X11, and Remmina to be installed in flatpak. +# RDP over Remmina on XWayland is the only way i've been able to have fractional scaling on the host, and GPU acceleration on the guest. +def main []: nothing -> nothing { + print "> Extracting hostname from vagrant..." + + let ip = (vagrant ssh-config | parse " {key} {val}" | transpose -r | get 0.HostName) + print $"> hostname: ($ip)" + + let user = "vagrant" + let pass = "vagrant" + + let uri = $"rdp://($user):($pass)@($ip)" + print $"> connecting to ($uri)" + + flatpak run --socket=fallback-x11 org.remmina.Remmina --no-tray-icon -c $uri +} + diff --git a/scripts/add-swedish-keyboard.ps1 b/scripts/add-swedish-keyboard.ps1 new file mode 100644 index 0000000..530e6ac --- /dev/null +++ b/scripts/add-swedish-keyboard.ps1 @@ -0,0 +1,3 @@ +$LanguageList = Get-WinUserLanguageList +$LanguageList.Add("sv-SE") +Set-WinUserLanguageList -Confirm -Force $LanguageList diff --git a/scripts/choco-install.ps1 b/scripts/choco-install.ps1 new file mode 100644 index 0000000..dde1de9 --- /dev/null +++ b/scripts/choco-install.ps1 @@ -0,0 +1,26 @@ +echo "Installing stuff from choco..." + +# TODO: zed +# TODO: visual studio +# TODO: c++ build tools? wdk? windows sdk? +choco install ` + croc ` + curl ` + firefox ` + git ` + helix ` + nushell ` + procmon ` + protoc ` + rustup.install ` + vcredist-all ` + visualstudio2022-workload-vctools ` + visualstudio2022-workload-universalbuildtools ` + visualstudio2022buildtools ` + volta ` + windows-sdk-11-version-22h2-all ` + zig ` + zoxide ` + --yes + +git config --system core.longpaths true diff --git a/scripts/enable-rdp.ps1 b/scripts/enable-rdp.ps1 new file mode 100644 index 0000000..292207d --- /dev/null +++ b/scripts/enable-rdp.ps1 @@ -0,0 +1,2 @@ +Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Value 0 +Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Value 1 diff --git a/scripts/get-mullvad-loader.ps1 b/scripts/get-mullvad-loader.ps1 new file mode 100644 index 0000000..792a663 --- /dev/null +++ b/scripts/get-mullvad-loader.ps1 @@ -0,0 +1 @@ +Invoke-WebRequest -Uri https://mullvad.net/en/download/installer/exe/latest -OutFile "Desktop/Mullvad Loader.exe" diff --git a/scripts/install-chocolatey.ps1 b/scripts/install-chocolatey.ps1 new file mode 100644 index 0000000..e7049d7 --- /dev/null +++ b/scripts/install-chocolatey.ps1 @@ -0,0 +1,781 @@ +<# + .SYNOPSIS + Downloads and installs Chocolatey on the local machine. + + .DESCRIPTION + Retrieves the Chocolatey nupkg for the latest or a specified version, and + downloads and installs the application to the local machine. + + .NOTES + ===================================================================== + Copyright 2017 - 2020 Chocolatey Software, Inc, and the + original authors/contributors from ChocolateyGallery + Copyright 2011 - 2017 RealDimensions Software, LLC, and the + original authors/contributors from ChocolateyGallery + at https://github.com/chocolatey/chocolatey.org + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ===================================================================== + + Environment Variables, specified as $env:NAME in PowerShell.exe and %NAME% in cmd.exe. + For explicit proxy, please set $env:chocolateyProxyLocation and optionally $env:chocolateyProxyUser and $env:chocolateyProxyPassword + For an explicit version of Chocolatey, please set $env:chocolateyVersion = 'versionnumber' + To target a different url for chocolatey.nupkg, please set $env:chocolateyDownloadUrl = 'full url to nupkg file' + NOTE: $env:chocolateyDownloadUrl does not work with $env:chocolateyVersion. + To use built-in compression instead of 7zip (requires additional download), please set $env:chocolateyUseWindowsCompression = 'true' + To bypass the use of any proxy, please set $env:chocolateyIgnoreProxy = 'true' + + .LINK + For organizational deployments of Chocolatey, please see https://docs.chocolatey.org/en-us/guides/organizations/organizational-deployment-guide + +#> +[CmdletBinding(DefaultParameterSetName = 'Default')] +param( + # The URL to download Chocolatey from. This defaults to the value of + # $env:chocolateyDownloadUrl, if it is set, and otherwise falls back to the + # official Chocolatey community repository to download the Chocolatey package. + # Can be used for offline installation by providing a path to a Chocolatey.nupkg. + [Parameter(Mandatory = $false)] + [string] + $ChocolateyDownloadUrl = $env:chocolateyDownloadUrl, + + # Specifies a target version of Chocolatey to install. By default, the latest + # stable version is installed. This will use the value in + # $env:chocolateyVersion by default, if that environment variable is present. + # This parameter is ignored if -ChocolateyDownloadUrl is set. + [Parameter(Mandatory = $false)] + [string] + $ChocolateyVersion = $env:chocolateyVersion, + + # If set, uses built-in Windows decompression tools instead of 7zip when + # unpacking the downloaded nupkg. This will be set by default if + # $env:chocolateyUseWindowsCompression is set to a value other than 'false' or '0'. + # + # This parameter will be ignored in PS 5+ in favour of using the + # Expand-Archive built in PowerShell cmdlet directly. + [Parameter(Mandatory = $false)] + [switch] + $UseNativeUnzip = $( + $envVar = "$env:chocolateyUseWindowsCompression".Trim() + $value = $null + if ([bool]::TryParse($envVar, [ref] $value)) { + $value + } elseif ([int]::TryParse($envVar, [ref] $value)) { + [bool]$value + } else { + [bool]$envVar + } + ), + + # If set, ignores any configured proxy. This will override any proxy + # environment variables or parameters. This will be set by default if + # $env:chocolateyIgnoreProxy is set to a value other than 'false' or '0'. + [Parameter(Mandatory = $false)] + [switch] + $IgnoreProxy = $( + $envVar = "$env:chocolateyIgnoreProxy".Trim() + $value = $null + if ([bool]::TryParse($envVar, [ref] $value)) { + $value + } + elseif ([int]::TryParse($envVar, [ref] $value)) { + [bool]$value + } + else { + [bool]$envVar + } + ), + + # Specifies the proxy URL to use during the download. This will default to + # the value of $env:chocolateyProxyLocation, if any is set. + [Parameter(ParameterSetName = 'Proxy', Mandatory = $false)] + [string] + $ProxyUrl = $env:chocolateyProxyLocation, + + # Specifies the credential to use for an authenticated proxy. By default, a + # proxy credential will be constructed from the $env:chocolateyProxyUser and + # $env:chocolateyProxyPassword environment variables, if both are set. + [Parameter(ParameterSetName = 'Proxy', Mandatory = $false)] + [System.Management.Automation.PSCredential] + $ProxyCredential +) + +#region Functions + +function Get-Downloader { + <# + .SYNOPSIS + Gets a System.Net.WebClient that respects relevant proxies to be used for + downloading data. + + .DESCRIPTION + Retrieves a WebClient object that is pre-configured according to specified + environment variables for any proxy and authentication for the proxy. + Proxy information may be omitted if the target URL is considered to be + bypassed by the proxy (originates from the local network.) + + .PARAMETER Url + Target URL that the WebClient will be querying. This URL is not queried by + the function, it is only a reference to determine if a proxy is needed. + + .EXAMPLE + Get-Downloader -Url $fileUrl + + Verifies whether any proxy configuration is needed, and/or whether $fileUrl + is a URL that would need to bypass the proxy, and then outputs the + already-configured WebClient object. + #> + [CmdletBinding()] + param( + [Parameter(Mandatory = $false)] + [string] + $Url, + + [Parameter(Mandatory = $false)] + [string] + $ProxyUrl, + + [Parameter(Mandatory = $false)] + [System.Management.Automation.PSCredential] + $ProxyCredential + ) + + $downloader = New-Object System.Net.WebClient + + $defaultCreds = [System.Net.CredentialCache]::DefaultCredentials + if ($defaultCreds) { + $downloader.Credentials = $defaultCreds + } + + if ($ProxyUrl) { + # Use explicitly set proxy. + Write-Host "Using explicit proxy server '$ProxyUrl'." + $proxy = New-Object System.Net.WebProxy -ArgumentList $ProxyUrl, <# bypassOnLocal: #> $true + + $proxy.Credentials = if ($ProxyCredential) { + $ProxyCredential.GetNetworkCredential() + } elseif ($defaultCreds) { + $defaultCreds + } else { + Write-Warning "Default credentials were null, and no explicitly set proxy credentials were found. Attempting backup method." + (Get-Credential).GetNetworkCredential() + } + + if (-not $proxy.IsBypassed($Url)) { + $downloader.Proxy = $proxy + } + } else { + Write-Host "Not using proxy." + } + + $downloader +} + +function Request-String { + <# + .SYNOPSIS + Downloads content from a remote server as a string. + + .DESCRIPTION + Downloads target string content from a URL and outputs the resulting string. + Any existing proxy that may be in use will be utilised. + + .PARAMETER Url + URL to download string data from. + + .PARAMETER ProxyConfiguration + A hashtable containing proxy parameters (ProxyUrl and ProxyCredential) + + .EXAMPLE + Request-String https://community.chocolatey.org/install.ps1 + + Retrieves the contents of the string data at the targeted URL and outputs + it to the pipeline. + #> + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string] + $Url, + + [Parameter(Mandatory = $false)] + [hashtable] + $ProxyConfiguration + ) + + (Get-Downloader $url @ProxyConfiguration).DownloadString($url) +} + +function Request-File { + <# + .SYNOPSIS + Downloads a file from a given URL. + + .DESCRIPTION + Downloads a target file from a URL to the specified local path. + Any existing proxy that may be in use will be utilised. + + .PARAMETER Url + URL of the file to download from the remote host. + + .PARAMETER File + Local path for the file to be downloaded to. + + .PARAMETER ProxyConfiguration + A hashtable containing proxy parameters (ProxyUrl and ProxyCredential) + + .EXAMPLE + Request-File -Url https://community.chocolatey.org/install.ps1 -File $targetFile + + Downloads the install.ps1 script to the path specified in $targetFile. + #> + [CmdletBinding()] + param( + [Parameter(Mandatory = $false)] + [string] + $Url, + + [Parameter(Mandatory = $false)] + [string] + $File, + + [Parameter(Mandatory = $false)] + [hashtable] + $ProxyConfiguration + ) + + Write-Host "Downloading $url to $file" + (Get-Downloader $url @ProxyConfiguration).DownloadFile($url, $file) +} + +function Set-PSConsoleWriter { + <# + .SYNOPSIS + Workaround for a bug in output stream handling PS v2 or v3. + + .DESCRIPTION + PowerShell v2/3 caches the output stream. Then it throws errors due to the + FileStream not being what is expected. Fixes "The OS handle's position is + not what FileStream expected. Do not use a handle simultaneously in one + FileStream and in Win32 code or another FileStream." error. + + .EXAMPLE + Set-PSConsoleWriter + + .NOTES + General notes + #> + + [CmdletBinding()] + param() + if ($PSVersionTable.PSVersion.Major -gt 3) { + return + } + + try { + # http://www.leeholmes.com/blog/2008/07/30/workaround-the-os-handles-position-is-not-what-filestream-expected/ plus comments + $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetField" + $objectRef = $host.GetType().GetField("externalHostRef", $bindingFlags).GetValue($host) + + $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetProperty" + $consoleHost = $objectRef.GetType().GetProperty("Value", $bindingFlags).GetValue($objectRef, @()) + [void] $consoleHost.GetType().GetProperty("IsStandardOutputRedirected", $bindingFlags).GetValue($consoleHost, @()) + + $bindingFlags = [Reflection.BindingFlags] "Instance,NonPublic,GetField" + $field = $consoleHost.GetType().GetField("standardOutputWriter", $bindingFlags) + $field.SetValue($consoleHost, [Console]::Out) + + [void] $consoleHost.GetType().GetProperty("IsStandardErrorRedirected", $bindingFlags).GetValue($consoleHost, @()) + $field2 = $consoleHost.GetType().GetField("standardErrorWriter", $bindingFlags) + $field2.SetValue($consoleHost, [Console]::Error) + } catch { + Write-Warning "Unable to apply redirection fix." + } +} + +function Test-ChocolateyInstalled { + [CmdletBinding()] + param() + + $checkPath = if ($env:ChocolateyInstall) { $env:ChocolateyInstall } else { "$env:PROGRAMDATA\chocolatey" } + + if ($Command = Get-Command choco -CommandType Application -ErrorAction Ignore) { + # choco is on the PATH, assume it's installed + Write-Warning "'choco' was found at '$($Command.Path)'." + $true + } + elseif (-not (Test-Path $checkPath)) { + # Install folder doesn't exist + $false + } + else { + # Install folder exists + if (Get-ChildItem -Path $checkPath) { + Write-Warning "Files from a previous installation of Chocolatey were found at '$($CheckPath)'." + } + + # Return true here to prevent overwriting an existing installation + $true + } +} + +function Install-7zip { + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string] + $Path, + + [Parameter(Mandatory = $false)] + [hashtable] + $ProxyConfiguration + ) + if (-not (Test-Path ($Path))) { + Write-Host "Downloading 7-Zip commandline tool prior to extraction." + Request-File -Url 'https://community.chocolatey.org/7za.exe' -File $Path -ProxyConfiguration $ProxyConfiguration + } + else { + Write-Host "7zip already present, skipping installation." + } +} + +#endregion Functions + +#region Pre-check + +# Ensure we have all our streams setup correctly, needed for older PSVersions. +Set-PSConsoleWriter + +if (Test-ChocolateyInstalled) { + $message = @( + "An existing Chocolatey installation was detected. Installation will not continue. This script will not overwrite existing installations." + "If there is no Chocolatey installation at '$env:ChocolateyInstall', delete the folder and attempt the installation again." + "" + "Please use `choco upgrade chocolatey` to handle upgrades of Chocolatey itself." + "If the existing installation is not functional or a prior installation did not complete, follow these steps:" + " - Backup the files at the path listed above so you can restore your previous installation if needed." + " - Remove the existing installation manually." + " - Rerun this installation script." + " - Reinstall any packages previously installed, if needed (refer to the `lib` folder in the backup)." + "" + "Once installation is completed, the backup folder is no longer needed and can be deleted." + ) -join [Environment]::NewLine + + Write-Warning $message + + return +} + +#endregion Pre-check + +#region Setup + +$proxyConfig = if ($IgnoreProxy -or -not $ProxyUrl) { + @{} +} else { + $config = @{ + ProxyUrl = $ProxyUrl + } + + if ($ProxyCredential) { + $config['ProxyCredential'] = $ProxyCredential + } elseif ($env:chocolateyProxyUser -and $env:chocolateyProxyPassword) { + $securePass = ConvertTo-SecureString $env:chocolateyProxyPassword -AsPlainText -Force + $config['ProxyCredential'] = [System.Management.Automation.PSCredential]::new($env:chocolateyProxyUser, $securePass) + } + + $config +} + +# Attempt to set highest encryption available for SecurityProtocol. +# PowerShell will not set this by default (until maybe .NET 4.6.x). This +# will typically produce a message for PowerShell v2 (just an info +# message though) +try { + # Set TLS 1.2 (3072) as that is the minimum required by Chocolatey.org. + # Use integers because the enumeration value for TLS 1.2 won't exist + # in .NET 4.0, even though they are addressable if .NET 4.5+ is + # installed (.NET 4.5 is an in-place upgrade). + Write-Host "Forcing web requests to allow TLS v1.2 (Required for requests to Chocolatey.org)" + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 +} +catch { + $errorMessage = @( + 'Unable to set PowerShell to use TLS 1.2. This is required for contacting Chocolatey as of 03 FEB 2020.' + 'https://blog.chocolatey.org/2020/01/remove-support-for-old-tls-versions/.' + 'If you see underlying connection closed or trust errors, you may need to do one or more of the following:' + '(1) upgrade to .NET Framework 4.5+ and PowerShell v3+,' + '(2) Call [System.Net.ServicePointManager]::SecurityProtocol = 3072; in PowerShell prior to attempting installation,' + '(3) specify internal Chocolatey package location (set $env:chocolateyDownloadUrl prior to install or host the package internally),' + '(4) use the Download + PowerShell method of install.' + 'See https://docs.chocolatey.org/en-us/choco/setup for all install options.' + ) -join [Environment]::NewLine + Write-Warning $errorMessage +} + +if ($ChocolateyDownloadUrl) { + if ($ChocolateyVersion) { + Write-Warning "Ignoring -ChocolateyVersion parameter ($ChocolateyVersion) because -ChocolateyDownloadUrl is set." + } + + Write-Host "Downloading Chocolatey from: $ChocolateyDownloadUrl" +} elseif ($ChocolateyVersion) { + Write-Host "Downloading specific version of Chocolatey: $ChocolateyVersion" + $ChocolateyDownloadUrl = "https://community.chocolatey.org/api/v2/package/chocolatey/$ChocolateyVersion" +} else { + Write-Host "Getting latest version of the Chocolatey package for download." + $queryString = [uri]::EscapeUriString("((Id eq 'chocolatey') and (not IsPrerelease)) and IsLatestVersion") + $queryUrl = 'https://community.chocolatey.org/api/v2/Packages()?$filter={0}' -f $queryString + + [xml]$result = Request-String -Url $queryUrl -ProxyConfiguration $proxyConfig + $ChocolateyDownloadUrl = $result.feed.entry.content.src +} + +if (-not $env:TEMP) { + $env:TEMP = Join-Path $env:SystemDrive -ChildPath 'temp' +} + +$chocoTempDir = Join-Path $env:TEMP -ChildPath "chocolatey" +$tempDir = Join-Path $chocoTempDir -ChildPath "chocoInstall" + +if (-not (Test-Path $tempDir -PathType Container)) { + $null = New-Item -Path $tempDir -ItemType Directory +} + +#endregion Setup + +#region Download & Extract Chocolatey + +$file = Join-Path $tempDir "chocolatey.zip" + +# If we are passed a valid local path, we do not need to download it. +if (Test-Path $ChocolateyDownloadUrl) { + Write-Host "Using Chocolatey from $ChocolateyDownloadUrl." + Copy-Item -Path $ChocolateyDownloadUrl -Destination $file +} else { + Write-Host "Getting Chocolatey from $ChocolateyDownloadUrl." + Request-File -Url $ChocolateyDownloadUrl -File $file -ProxyConfiguration $proxyConfig +} + +Write-Host "Extracting $file to $tempDir" +if ($PSVersionTable.PSVersion.Major -lt 5) { + # Determine unzipping method + # 7zip is the most compatible pre-PSv5.1 so use it unless asked to use builtin + if ($UseNativeUnzip) { + Write-Host 'Using built-in compression to unzip' + + try { + $shellApplication = New-Object -ComObject Shell.Application + $zipPackage = $shellApplication.NameSpace($file) + $destinationFolder = $shellApplication.NameSpace($tempDir) + $destinationFolder.CopyHere($zipPackage.Items(), 0x10) + } catch { + Write-Warning "Unable to unzip package using built-in compression. Set `$env:chocolateyUseWindowsCompression = ''` or omit -UseNativeUnzip and retry to use 7zip to unzip." + throw $_ + } + } else { + $7zaExe = Join-Path $tempDir -ChildPath '7za.exe' + Install-7zip -Path $7zaExe -ProxyConfiguration $proxyConfig + + $params = 'x -o"{0}" -bd -y "{1}"' -f $tempDir, $file + + # use more robust Process as compared to Start-Process -Wait (which doesn't + # wait for the process to finish in PowerShell v3) + $process = New-Object System.Diagnostics.Process + + try { + $process.StartInfo = New-Object System.Diagnostics.ProcessStartInfo -ArgumentList $7zaExe, $params + $process.StartInfo.RedirectStandardOutput = $true + $process.StartInfo.UseShellExecute = $false + $process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden + + $null = $process.Start() + $process.BeginOutputReadLine() + $process.WaitForExit() + + $exitCode = $process.ExitCode + } + finally { + $process.Dispose() + } + + $errorMessage = "Unable to unzip package using 7zip. Perhaps try setting `$env:chocolateyUseWindowsCompression = 'true' and call install again. Error:" + if ($exitCode -ne 0) { + $errorDetails = switch ($exitCode) { + 1 { "Some files could not be extracted" } + 2 { "7-Zip encountered a fatal error while extracting the files" } + 7 { "7-Zip command line error" } + 8 { "7-Zip out of memory" } + 255 { "Extraction cancelled by the user" } + default { "7-Zip signalled an unknown error (code $exitCode)" } + } + + throw ($errorMessage, $errorDetails -join [Environment]::NewLine) + } + } +} else { + Microsoft.PowerShell.Archive\Expand-Archive -Path $file -DestinationPath $tempDir -Force +} + +#endregion Download & Extract Chocolatey + +#region Install Chocolatey + +Write-Host "Installing Chocolatey on the local machine" +$toolsFolder = Join-Path $tempDir -ChildPath "tools" +$chocoInstallPS1 = Join-Path $toolsFolder -ChildPath "chocolateyInstall.ps1" + +& $chocoInstallPS1 + +Write-Host 'Ensuring Chocolatey commands are on the path' +$chocoInstallVariableName = "ChocolateyInstall" +$chocoPath = [Environment]::GetEnvironmentVariable($chocoInstallVariableName) + +if (-not $chocoPath) { + $chocoPath = "$env:ALLUSERSPROFILE\Chocolatey" +} + +if (-not (Test-Path ($chocoPath))) { + $chocoPath = "$env:PROGRAMDATA\chocolatey" +} + +$chocoExePath = Join-Path $chocoPath -ChildPath 'bin' + +# Update current process PATH environment variable if it needs updating. +if ($env:Path -notlike "*$chocoExePath*") { + $env:Path = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine); +} + +Write-Host 'Ensuring chocolatey.nupkg is in the lib folder' +$chocoPkgDir = Join-Path $chocoPath -ChildPath 'lib\chocolatey' +$nupkg = Join-Path $chocoPkgDir -ChildPath 'chocolatey.nupkg' + +if (-not (Test-Path $chocoPkgDir -PathType Container)) { + $null = New-Item -ItemType Directory -Path $chocoPkgDir +} + +Copy-Item -Path $file -Destination $nupkg -Force -ErrorAction SilentlyContinue + +#endregion Install Chocolatey + +# SIG # Begin signature block +# MIInKwYJKoZIhvcNAQcCoIInHDCCJxgCAQExDzANBglghkgBZQMEAgEFADB5Bgor +# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG +# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDh6HLVOQJ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3DQEHATAcBgkqhkiG9w0BCQUxDxcNMjQwNTE0MDY1ODU4WjAvBgkq +# hkiG9w0BCQQxIgQg3Bf25u0skV7YV8kyqOny0RxKb+Lc+u9Qa/ohRGvxa+IwDQYJ +# KoZIhvcNAQEBBQAEggIAGIYJbugrkx3VpWoeAmOJ91tlVc6dnkw1Pi/T2vgqwnrG +# pjQ3j/4GawHnMJUNAQlbZF8MLLuybOHZO9Y76sg14B7sUiNHXjZKkbNYeYjPrabF +# dn/WjFvifkJIoSnrf2aSrk1bThjdY0ZZ3Qz8D9w5vgIKyaTkpfKFHg5w71vUEqFc +# 5Nlt9CRQHJCcjYq7JtDWrT+EJ6/U7eL4doPsCMER27m9t942L661yOUoTAYVqZEO +# oTN0KepwECODgjyUWSGATFpxteGOYkimh4dj5PiT1huAqSWRbd56N0GgiTj1cqvi +# FxM1JXZ4kpIxVtIbixGWyjYS3FR8slXd5knOqBQk9My8jAlyNO9ukXhmyzYpfYzj +# 1EIU37abmKqZ/Yx7PvX+RGwAgLKdayniab2PLy2yhrI7YrXQgTZC3Yun58CDb+Uz +# 2CdaG+opDhRg6/VrG6GjkyS1dUAI3O/qkjg9wDZ0U2UwQiEs132pllViqTY8DJz4 +# FIaQ2jUZuYkCkHy9sgMR5izWGLSxD3SL3Dka3CcA2xyhO/j2axsn5wBl0lLRPL/I +# 9adzX5USDrS0qd+ES5B/KXaL938Zf2hG4igDCIyoXxo8Lc5mlq8JspKOgxXUam48 +# atMzo5XpFacHe3Ewx+IvBa1QvjieO+WsiRWMVsDCaXwLjpJPE2jLJQloM9asv+A= +# SIG # End signature block diff --git a/scripts/restart-explorer.ps1 b/scripts/restart-explorer.ps1 new file mode 100644 index 0000000..d8f0be7 --- /dev/null +++ b/scripts/restart-explorer.ps1 @@ -0,0 +1,3 @@ +Stop-Process -Name explorer -Force +Start-Sleep -Seconds 2 +Start-Process explorer diff --git a/scripts/setup-nu.ps1 b/scripts/setup-nu.ps1 new file mode 100644 index 0000000..19bcdc7 --- /dev/null +++ b/scripts/setup-nu.ps1 @@ -0,0 +1,13 @@ +# Invoke nu to ensure that the `env.nu` file exists +nu --login --commands "echo 'hello from nu'" + +# TODO: consider adding these using regedit or something +Add-Content -Path "$HOME/AppData/Roaming/nushell/env.nu" -Value @' + +$env.PATH ++= [ + 'C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\MSBuild\Current\Bin' + 'C:\ProgramData\chocolatey\bin' + 'C:\Program Files\Git\cmd' + 'C:\Program Files\Volta' +] +'@ diff --git a/scripts/theme.ps1 b/scripts/theme.ps1 new file mode 100644 index 0000000..fd5afb5 --- /dev/null +++ b/scripts/theme.ps1 @@ -0,0 +1,37 @@ +# Modify Windows 10/11 or Server theme (Light or Dark mode). Makes registry changes which +# take effect upon reboot, or explorer.exe restart. Bypasses restriction to change theme on +# unactivated Windows installations. +# +# Usage: +# To switch to dark mode, run: .\theme.ps1 -Mode dark +# To switch to light mode, run: .\theme.ps1 -Mode light +# +# Optional: Restart the explorer.exe process: +# "Stop-Process -Name explorer -Force; Start-Sleep -Seconds 2; Start-Process explorer" + +param ( + [Parameter(Mandatory=$true)] + [ValidateSet("light", "dark")] + [string]$Mode +) + +function Set-DarkTheme { + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "SystemUsesLightTheme" -Value 0 + Write-Host -f Yellow "Dark theme enabled.`n" +} + +function Set-LightTheme { + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "SystemUsesLightTheme" -Value 1 + Write-Host -f Yellow "Light theme enabled.`n" +} + +switch ($Mode) { + "dark" { + Set-DarkTheme + } + "light" { + Set-LightTheme + } +} diff --git a/scripts/win11-debloat.ps1 b/scripts/win11-debloat.ps1 new file mode 100644 index 0000000..b4ef93e --- /dev/null +++ b/scripts/win11-debloat.ps1 @@ -0,0 +1,2 @@ +# https://github.com/Raphire/Win11Debloat +& ([scriptblock]::Create((irm "https://debloat.raphi.re/"))) -RunDefaults