Documentation
¶
Overview ¶
Package winkit builds Windows VM images from code. This root package is the library entry point consumers embed (devcell, CI pipelines): fill a build.Config, call Build, get a disk image. The winkit CLI is a thin frontend over the same call.
The contract: winkit owns the verbs (fetch, service, install, import, execute hooks, package); the consumer owns the nouns (which WSL image, which services, which packages) via buildopts.BuildOpts and hooks. See the examples/ directory for both YAML and library consumers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build produces a Windows image from cfg, dispatching on cfg.Opts: PE mode assembles a WinPE boot volume, a WSL config runs a full install with the distro imported, otherwise a base install runs. cfg.Opts may be nil (defaults apply). Dest, WindowsISO and VirtIOISO are required; an empty WorkDir gets a temp dir that is removed when Build returns.
Types ¶
type StartOpts ¶
type StartOpts struct {
// Image is the built disk image to boot (qcow2 for QEMU).
Image string
// Name identifies the VM in state/status; defaults to the image
// filename without extension.
Name string
// Hostname is applied as the guest computer name via the SMBIOS
// serial on next boot; defaults to the unattend default.
Hostname string
// Accel selects the accelerator (kvm, hvf, tcg); default: best for
// the host.
Accel string
// StateDir holds running-VM state for Status/stop; default
// ~/.winkit/run.
StateDir string
CPUs uint
MemoryGB uint64
// SSHPort forwards to the guest provisioning SSH (gosshd, :2222).
// The delivered Windows OpenSSH lands on SSHPort+100.
SSHPort uint16
RDPPort uint16
// Foreground keeps the VM attached to the calling process; the
// default detaches it so the handle outlives the caller.
Foreground bool
// VNCPort selects the host VNC port (default 5900). VNC is always enabled.
VNCPort uint16
// Forwards are extra host→guest TCP forwards (winkit.yaml ports.forward,
// `winkit start --forward host:guest`).
Forwards []vm.PortForward
// Logger receives host-side events; nil logs to run.jsonl in the
// VM's output directory.
Logger *slog.Logger
}
StartOpts configures Start. Only Image is required; zero values get the CLI's defaults (4 vCPUs, 6 GB, SSH 20022, RDP 23389, backend auto-detected).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package build orchestrates full unattended Windows image builds: media prep, answer volume, VM install, provisioning over gosshd, verification, and clean shutdown.
|
Package build orchestrates full unattended Windows image builds: media prep, answer volume, VM install, provisioning over gosshd, verification, and clean shutdown. |
|
Package cache resolves where winkit stores large downloaded artifacts: installer ISOs, driver ISOs and the ESD files they are assembled from.
|
Package cache resolves where winkit stores large downloaded artifacts: installer ISOs, driver ISOs and the ESD files they are assembled from. |
|
cmd
|
|
|
winkit
command
Command winkit is the host-side CLI over the go-winkit packages: fetch Windows install media, build bootable and WinPE ISOs, generate and validate autounattend answer files, patch WIMs, and read guest diagnostics.
|
Command winkit is the host-side CLI over the go-winkit packages: fetch Windows install media, build bootable and WinPE ISOs, generate and validate autounattend answer files, patch WIMs, and read guest diagnostics. |
|
winkit-service
command
Command winkit-service wraps an arbitrary command as a system service.
|
Command winkit-service wraps an arbitrary command as a system service. |
|
examples
|
|
|
library-consumer
command
Command library-consumer is the devcell-shaped reference consumer of winkit's Go API: no winkit.yaml, everything programmatic.
|
Command library-consumer is the devcell-shaped reference consumer of winkit's Go API: no winkit.yaml, everything programmatic. |
|
Package gosshd is an SSH server for WinPE guests.
|
Package gosshd is an SSH server for WinPE guests. |
|
cmd/gosshd
command
Command gosshd is the SSH server staged into a guest.
|
Command gosshd is the SSH server staged into a guest. |
|
internal
|
|
|
cli
Package cli implements the winkit command tree.
|
Package cli implements the winkit command tree. |
|
iotrace
Package iotrace records the IO a build performs: files opened and written, WIM images exported, images mastered, bytes downloaded.
|
Package iotrace records the IO a build performs: files opened and written, WIM images exported, images mastered, bytes downloaded. |
|
templates
Package templates holds the guest PowerShell scripts shipped by winkit.
|
Package templates holds the guest PowerShell scripts shipped by winkit. |
|
Package media is winkit's install-media fetch policy: which source serves the Windows installer ISO, in what order, and with what fallback.
|
Package media is winkit's install-media fetch policy: which source serves the Windows installer ISO, in what order, and with what fallback. |
|
virtio
Package virtio downloads the virtio-win driver ISO, the source of the storage, serial and network drivers WinPE needs to see a QEMU guest's devices.
|
Package virtio downloads the virtio-win driver ISO, the source of the storage, serial and network drivers WinPE needs to see a QEMU guest's devices. |
|
Package s6 models s6 service directories: the unit of supervision under an s6-svscan scan dir (in winkit's WSL distro, /etc/s6/services).
|
Package s6 models s6 service directories: the unit of supervision under an s6-svscan scan dir (in winkit's WSL distro, /etc/s6/services). |
|
Package sftpshare serves a host directory to VM guests over SFTP.
|
Package sftpshare serves a host directory to VM guests over SFTP. |
|
tools
|
|
|
renderps1
command
renderps1 renders the embedded PowerShell templates with representative sample data so PSScriptAnalyzer can lint the actual scripts a consumer ships.
|
renderps1 renders the embedded PowerShell templates with representative sample data so PSScriptAnalyzer can lint the actual scripts a consumer ships. |
|
seedstatus
command
Command seedstatus prints the cache paths the real-media tests read and whether each one is seeded.
|
Command seedstatus prints the cache paths the real-media tests read and whether each one is seeded. |
|
vmkey
command
Command vmkey drives a running QEMU guest's keyboard over its QMP socket, so you can interact with a VM that has no working network yet (e.g.
|
Command vmkey drives a running QEMU guest's keyboard over its QMP socket, so you can interact with a VM that has no working network yet (e.g. |
|
Package vm is the backend-agnostic VM layer: the VM and VMBackend interfaces, install/run configuration, and disk-format types.
|
Package vm is the backend-agnostic VM layer: the VM and VMBackend interfaces, install/run configuration, and disk-format types. |
|
vmstate
Package vmstate tracks running winkit VMs via JSON state files.
|
Package vmstate tracks running winkit VMs via JSON state files. |
|
Package wsl builds WSL 1-compatible rootfs tarballs (.wsl) from Docker images.
|
Package wsl builds WSL 1-compatible rootfs tarballs (.wsl) from Docker images. |