Skip to content

karlgluck/swiss-chocolatey-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SWISS Chocolatey Lab

Set up a Workstation Instantly with Simple Scripts... using Chocolatey and AutomatedLab!

Swiss Chocolatey Lab (SCL) runs disposable developer environments on a Windows 11 PC. It supports both public and private repositories.

Usage

  • Install a fresh copy of Windows 11 Pro
  • Install graphics drivers manually (nvidia)
  • Set up a GitHub Personal Access Token with repo and org:read scopes
  • Optional: install Parsec manually to meta-manage remotely

Quick Start - Windows Sandbox

The easiest way to experiment with SCL is to run it in a Windows Sandbox. Copy and paste this command into an admin PowerShell terminal in your sandbox:

For read-only use of public repositories:

Set-ExecutionPolicy Bypass -Scope Process -Force ; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 ; (Invoke-WebRequest -Method Get -Uri ($__URL = (Read-Host -Prompt "Update-SwissSandbox.ps1") -replace "github\.com\/(.*)\/blob\/(.*)",'raw.githubusercontent.com/$1/$2') -Headers @{'Cache-Control'='no-store'}).Content | Invoke-Expression ; Update-SwissSandbox -Bootstrap ([PSCustomObject]@{HostUrl=$__URL; ProjectUrl=(Read-Host -Prompt "Project GitHub Repository")}) ; Remove-Variable @('__URL')

For full access and private repositories:

Set-ExecutionPolicy Bypass -Scope Process -Force ; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 ; (Invoke-WebRequest -Method Get -Uri ($__URL = (Read-Host -Prompt "Update-SwissSandbox.ps1") -replace "github\.com\/(.*)\/blob\/(.*)",'raw.githubusercontent.com/$1/$2') -Headers @{Authorization=@('token ',($__TOKEN = Read-Host -Prompt "GitHub Token")) -join ''; 'Cache-Control'='no-store'}).Content | Invoke-Expression ; Update-SwissSandbox -Bootstrap ([PSCustomObject]@{Token=$__TOKEN; HostUrl=$__URL; ProjectUrl=(Read-Host -Prompt "Project GitHub Repository")}) ; Remove-Variable @('__TOKEN','__URL')

You will be asked to provide additional input:

  1. Copy-paste the URL to Update-SwissSandbox.ps1 into the first prompt for "Update-SwissSandbox.ps1". This lets SCL know where to find its own code for self-updating.
  2. Paste your GitHub Personal Access Token into the second prompt for "GitHub Token"
  3. Paste the URL of the repository you want to load into the third prompt for "GitHub Repository"

The configuration defined in the target repository's .swiss directory is used to set up the sandbox environment. If the repository doesn't have one, you can explore using choco install \<package name> to install packages. Once setup completes, you'll find the repository available under the C:/ drive.

The major limitation to running SCL in a sandbox is that everything is lost when it shuts down. This means you can't install software that requires rebooting or save your session when the host restarts.

Full Install - Hyper-V

SCL can also use Hyper-V to create developer environments. This will let you pause, resume and even checkpoint your environments.

SCL is built to run on a fresh installation of Windows 11 that does nothing but host these VM's, and there is currently no uninstall script. It doesn't do anything irreversible, but the changes to the environment can be extensive.

To get started, press Win+X,A to open an admin PowerShell terminal. Then, copy and paste the following bootstrap script into PowerShell:

Set-ExecutionPolicy Bypass -Scope Process -Force ; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 ; (Invoke-WebRequest -Method Get -Uri ($__URL = (Read-Host -Prompt "Update-SwissHost.ps1") -replace "github\.com\/(.*)\/blob\/(.*)",'raw.githubusercontent.com/$1/$2') -Headers @{Authorization=@('token ',($__TOKEN = Read-Host -Prompt "GitHub Token")) -join ''; 'Cache-Control'='no-store'}).Content | Invoke-Expression ; Update-SwissHost -Bootstrap ([PSCustomObject]@{Token=$__TOKEN; Url=$__URL}) ; Remove-Variable @('__TOKEN','__URL')

You will be asked to provide two additional inputs:

  1. Copy-paste the URL to Update-SwissHost.ps1 into the first prompt for "Update-SwissHost.ps1"
  2. Paste your GitHub Personal Access Token into the second prompt for "GitHub Token"

Bootstrapping will then continue. If this is the first time you're running this on a fresh host, installing Hyper-V will require restarting your computer. You will need to manually run Update-SwissHost after rebooting to continue.

Once the setup script completes, you're ready to install a virtual machine.

Managing a VM

On the host in an administrator PowerShell terminal with any of these commands:

Install-SwissVM
Install-SwissVM <repository>
Install-SwissVM -Repository <repository> -Branch <branch> -VMName <name> -UseCommonConfig <name>

By default, Install-SwissVM reads from the main branch and will create a VM with the same name as the repository.

-UseCommonConfig allows you to install a SwissVM without having to edit the repository by grabbing one of the *.swissguest files from the Config folder in this repository.

Login credentials will be your GitHub username with the name of the repository as a password.

After creation, launch the VM on the host:

Start-SwissVM <name>

Once connected to a VM, you can always update the environment:

GUEST> Update-SwissVM

Once you're done with a VM, disposing of it on the host is done with:

Remove-SwissVM <name>

Configuring a repository

Repositories use the /.swiss subdirectory to store their own environment setup configuration and scripts:

File Description
/.swiss/config.json Top-level configuration object. Example
/.swiss/packages.config Chocolatey package file definition, installed and updated automatically

Other useful commands

  • If you're not sure which VM's are available, use Get-SwissVM for a list
  • explorer ($env:PSModulePath -split ';')[0] opens the folder where SCL is installed

About

Create disposable dev environment VM's for GitHub repositories

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published