Skip to content
Edit this page

001: Runner and Prefix Management

Context

Linux distributions package inconsistent Wine releases and frequently omit 32-bit multilib libraries. Because of that mismatch, Windows toolchains fail unpredictably across developer machines and CI images. winesmith standardizes Wine and Proton acquisition alongside isolated and shared Windows 7, 10, and 11 prefixes.

Benchmark

Two reference approaches shaped the design of runner downloads and prefix scoping:

  • Bottles and Lutris download portable Wine builds effectively, yet bind workflows to desktop GUIs without lockfile digests, headless CLI flags, or spec-hashed prefix sharing.
  • Modern package tools such as rustup and uv store pinned binaries under local XDG caches without touching global distro packages, and winesmith follows that model for Wine runners and prefixes.

Interaction flow

Runner resolution and prefix initialization follow eight sequential steps:

  1. Merge [runner], [windows], and [prefix] settings across configuration layers.
  2. Select the pinned Kron4ek Wine 10 staging-amd64-wow64 release when [runner] is omitted.
  3. Check $XDG_DATA_HOME/winesmith/runners/ for portable kron4ek or ge-proton builds, downloading missing archives to $XDG_CACHE_HOME/winesmith/downloads/, checking SHA-256 or SHA-512 checksums, and unpacking atomically.
  4. Resolve system Wine or Steam proton runners from host PATH, explicit wine:/proton: paths, or Steam libraryfolders.vdf manifests.
  5. Derive the target prefix directory under $XDG_DATA_HOME/winesmith/prefixes/, using explicit [prefix].name or a spec hash under shared mode and a project-path hash under isolated mode.
  6. Acquire an exclusive fs4 advisory lock on <prefix>/.winesmith.lock.
  7. Boot the prefix with WINEDLLOVERRIDES="mscoree,mshtml=" to block Mono and Gecko installers, run winecfg -v <win7|win10|win11>, and disable crash dialogs (ShowCrashDialog = 0). Then create dosdevices/ mounts and drive_c symlinks and write winesmith-state.json.
  8. Compare desired settings against winesmith-state.json on later runs, reconciling safe drift (mounts, symlinks, Windows version, registry entries) in place and blocking breaking architecture or Proton layout changes until --reinstall is passed.

Visual design

This state diagram outlines how winesmith handles missing runners, prefix locks, first-time boot, and drift reconciliation:

stateDiagram-v2
    [*] --> ResolveRunner
    ResolveRunner --> DownloadVerify: Portable missing
    ResolveRunner --> AcquireLock: Runner ready
    DownloadVerify --> AcquireLock: Checksum verified
    AcquireLock --> BootPrefix: Prefix missing
    AcquireLock --> CheckDrift: winesmith-state.json exists
    BootPrefix --> ConfigureWindows: Apply win7/win10/win11 and suppress dialogs
    CheckDrift --> ConfigureWindows: Safe drift detected
    CheckDrift --> Ready: State matches
    ConfigureWindows --> ApplyMounts: Apply mounts, symlinks, overrides
    ApplyMounts --> WriteState
    WriteState --> Ready
    Ready --> [*]

Implementation

Manifest configuration fields

Projects configure Windows version, runner backend, prefix mode, drive mounts, and symlinks inside winesmith.toml:

[windows]
version = "win10"                    # "win7" | "win10" | "win11"
arch = "win64"                       # "win64" | "win32"
display = "none"                     # "none" | "xvfb" | "host"
wineserver_persist_secs = 30

[runner]
kind = "kron4ek"                     # "kron4ek" | "system" | "proton" | "ge-proton"
version = "10.0-staging-amd64-wow64" # or "10.0-staging-amd64" for multiarch win32

[prefix]
mode = "shared"                      # "shared" | "isolated"
# name = "neorune-net10"

[mounts]
w = "."

[symlinks]
"users/steamuser/AppData/Local/App/Saved" = "/path/on/host/Saved"

Edge cases and constraints

Three runtime details keep Wine and Proton prefixes consistent and safe under retries:

  • Proton places drive_c inside <prefix>/pfx/drive_c and requires STEAM_COMPAT_CLIENT_INSTALL_PATH plus STEAM_COMPAT_DATA_PATH, so RunnerLayout and PreparedPrefix normalize user profile and drive paths across vanilla Wine and Proton.
  • Kron4ek staging-amd64-wow64 runs 32-bit Windows binaries inside a 64-bit prefix without host 32-bit multilib libraries, whereas legacy WINEARCH=win32 setups require a multiarch Kron4ek build (staging-amd64), system Wine, or Proton.
  • Downloads stream into temporary .part files and move into $XDG_CACHE_HOME/winesmith/downloads/ only after hash checks pass, removing partial files when verification fails.