002: Toolchain Recipes and Lockfile¶
- Status: Developed
- Date: 2026-12-02
- Author(s): João V. Farias
- Traces to: ADR-006 Categories 1 and 5
Context¶
Installing Windows SDKs inside Wine by hand requires tracking direct installer URLs, bypassing GUI wizards, setting PATH and shared cache directories, and repairing upstream quirks. Built-in recipes automate common Windows SDKs and packagers alongside a generic installer primitive and SHA-256 lockfile verification.
Benchmark¶
Two packaging ecosystems guided recipe inputs and lockfile separation:
- Windows package managers such as Scoop and Chocolatey simplify interactive setup on Windows, yet add PowerShell bootstrap overhead inside Wine and lack CI-enforced SHA-256 lockfiles for downloads.
- Cargo and
uvseparate declared dependencies (winesmith.toml) from resolved URLs and hashes (winesmith.lock) so CI can check artifacts under--locked.
Interaction flow¶
Toolchain provisioning runs inside an exclusive prefix lock in five stages:
- Merge default
[toolchains]settings with any[targets.<name>].toolchainsor--toolchainCLI overrides. - Check Windows OS compatibility rules and print warnings on
stderrwhenwin7pairs with incompatible versions (.NET 7+,Python 3.9+, orInno Setup 7+). - Resolve download URLs and SHA-256 hashes from
winesmith.lock(failing with exit code3under--lockedif missing or mismatched with inline manifestsha256fields). - Execute optional
winetricks -q <verb>entries once per prefix state. - Download uncached SDKs into
$XDG_CACHE_HOME/winesmith/downloads/and verify SHA-256 checksums before unpacking.zip,.nupkg,.tar.xz,.tar.gz, or.7zarchives or running.msi/.exeinstallers. SavePATH, environment variables, DLL overrides, registry entries, andpost_installsignatures towinesmith-state.json, and updatewinesmith.lockwhen unlocked.
Visual design¶
The flowchart below traces toolchain declarations through compatibility warnings, cache lookup, archive extraction or installation, and state updates:
flowchart LR
Toml["winesmith.toml [toolchains]"] --> Compat["OS Compatibility Check"]
Lock["winesmith.lock (--locked)"] --> Resolve["Resolve URL + SHA-256"]
Compat --> Resolve
Resolve --> Cache["Download & Verify Cache"]
Cache --> Apply["Extract / Unattended Install"]
Apply --> Env["Register PATH, Env & DLL Overrides"]
Env --> Hooks["Run Wine / Host post_install Hooks"]
Hooks --> State["Update winesmith-state.json & winesmith.lock"]
Implementation¶
Built-in v1 recipes¶
Four built-in recipes cover common compilation and Windows packaging toolchains:
| Recipe | Artifacts and steps | Registered Windows PATH and env |
|---|---|---|
dotnet |
Official dotnet-sdk-<ver>-win-x64.zip or win-x86.zip, templates = [...], and global tools = [...] (install with update fallback). |
C:\dotnet and user .dotnet\tools on PATH, DOTNET_ROOT=C:\dotnet, telemetry disabled, optional host ~/.nuget/packages mapped to NUGET_PACKAGES. |
python |
Portable NuGet .nupkg (python or pythonx86) extracting tools/ into C:\python, ensurepip, and pip install for packages. |
C:\python and C:\python\Scripts on PATH, PYTHONUTF8=1, shared PIP_CACHE_DIR. |
inno |
GitHub release installer (innosetup-<ver>.exe for v6, -x64/-x86 for v7+) run with /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /CURRENTUSER /DIR=C:\tools\inno. |
C:\tools\inno on PATH for ISCC.exe. |
nsis |
Portable SourceForge nsis-<ver>.zip unpacked into C:\tools\nsis with its top wrapper directory stripped. |
C:\tools\nsis on PATH for makensis.exe. |
Generic custom recipe schema¶
Any SDK or runtime installer unavailable as a built-in recipe can be declared under [toolchains.custom.<name>] using either extract_to or installer_args:
[toolchains.custom.my_sdk]
url = "https://example.com/my-sdk-1.2.zip"
sha256 = "0123456789abcdef..."
extract_to = "C:\\tools\\my-sdk"
# installer_args = ["/VERYSILENT", "/NORESTART"] # used for .exe or .msi instead of extract_to
path = ["C:\\tools\\my-sdk\\bin"]
env = { MY_SDK_HOME = "C:\\tools\\my-sdk" }
dll_overrides = { "msvcp140" = "native,builtin" }
registry = [
{ key = "HKCU\\Software\\MySdk", value = "Version", kind = "REG_SZ", data = "1.2" }
]
winetricks = []
post_install = [
{ wine = "my-sdk-tool --init" },
{ host = "python3 scripts/patch.py '{{ prefix_drive_c }}/tools/my-sdk/tool.dll'" }
]
Lockfile schema¶
winesmith setup records the resolved runner and every recipe artifact in winesmith.lock:
lock_version = 1
[runner]
kind = "kron4ek"
version = "10.0-staging-amd64-wow64"
url = "https://github.com/Kron4ek/Wine-Builds/releases/download/10.0/wine-10.0-staging-amd64-wow64.tar.xz"
sha256 = "..."
[[artifacts]]
recipe = "dotnet"
version = "10.0.403"
arch = "win64"
url = "https://builds.dotnet.microsoft.com/dotnet/Sdk/10.0.403/dotnet-sdk-10.0.403-win-x64.zip"
sha256 = "..."
Edge cases and constraints¶
Recipe execution skips redundant work while keeping --locked verification strict:
- Re-running
winesmith setupskips already-installed recipes unless version, URL, SHA-256, completed hook signature, or--reinstallchanges. - Locked runs check
winesmith.lockentries even when a prefix already contains the recipe files, aborting if a lockfile checksum changed. provision_allruns internal Wine commands viarun_in_wine_unlockedwhile holding the exclusivePrefixLockso child Wine calls never deadlock on a nested shared flock.