Vagrant.configure("2") do |config|
config.vm.box = "gusztavvargadr/windows-server-2022-standard-core"
config.vm.communicator = "winrm"
config.winrm.username = "vagrant"
config.winrm.password = "vagrant"
config.winrm.timeout = 600
config.vm.provider "libvirt" do |lv|
lv.driver = "kvm"
lv.memory = 2048
lv.cpus = 2
end
config.vm.synced_folder ".", "/cygdrive/c/vagrant", type: "rsync",
rsync__exclude: [".git/", "target/", ".jj/"],
rsync__args: ["--verbose", "--archive", "--delete", "--copy-links", "--no-owner", "--no-group"]
config.vm.provision "shell", privileged: true, inline: <<-'POWERSHELL'
$ErrorActionPreference = "Stop"
# --- Chocolatey -------------------------------------------------------------
Write-Host "==> Installing Chocolatey..."
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol =
[System.Net.ServicePointManager]::SecurityProtocol -bor 3072
Invoke-Expression (
(New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')
)
}
# --- OpenSSH Server ---------------------------------------------------------
# The box ships with Win32-OpenSSH binaries at C:\Program Files\OpenSSH-Win64.
# Re-run install-sshd.ps1 to register the service (idempotent; safe to
# re-run if the service is already present).
Write-Host "==> Registering and starting sshd..."
& "C:\Program Files\OpenSSH-Win64\install-sshd.ps1"
Set-Service -Name sshd -StartupType Automatic
Start-Service -Name sshd
# Use PowerShell as the default shell for SSH sessions.
$regPath = "HKLM:\SOFTWARE\OpenSSH"
if (-not (Test-Path $regPath)) { New-Item -Path $regPath -Force | Out-Null }
Set-ItemProperty -Path $regPath -Name DefaultShell `
-Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
# Allow inbound SSH through the Windows firewall.
$rule = Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue
if (-not $rule) {
New-NetFirewallRule -Name "OpenSSH-Server-In-TCP" `
-DisplayName "OpenSSH Server (sshd)" `
-Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
}
# --- Rust, Git, rsync -------------------------------------------------------
Write-Host "==> Installing Rust, Git, rsync, and MinGW..."
choco install -y rust git rsync mingw
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") +
";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
# Add MinGW bin to the persistent system PATH so dlltool.exe is found in
# SSH sessions (which don't run the Chocolatey shim refresh).
$mingwBin = "C:\ProgramData\mingw64\mingw64\bin"
$machinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine")
if ($machinePath -notlike "*$mingwBin*") {
[System.Environment]::SetEnvironmentVariable("Path", "$machinePath;$mingwBin", "Machine")
}
Write-Host ""
Write-Host "==> Provisioning complete."
Write-Host " SSH into the VM: vagrant ssh-config (then ssh to the reported IP)"
Write-Host " Build skim: cd C:\vagrant && cargo build"
POWERSHELL
end