Skip to content
BeyondMagicPublic

About

Compile and package Windows 7, 10, and 11 software on Linux inside reproducible Wine and Proton environments without a virtual machine.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

winesmith

Compile, test, and package Windows 7, 10, and 11 software on Linux inside Wine and Proton environments without a virtual machine.

winesmith is a standalone Rust CLI that downloads pinned Wine and Proton runners, builds reproducible Windows prefixes, and installs Windows toolchains declaratively. It also executes hybrid Wine and Linux host tasks from winesmith.toml and integrates with Nushell 0.117+.

Capabilities

The CLI handles runner provisioning, prefix management, SDK installation, task execution, and shell completion:

  • Portable Kron4ek Wine 10 WoW64 builds (10.0-staging-amd64-wow64) download and unpack without host 32-bit multilib packages, alongside system Wine, Steam proton discovered via libraryfolders.vdf, ge-proton, or explicit paths (wine:/path, proton:/path).
  • Shared named or spec-hashed prefixes under $XDG_DATA_HOME/winesmith/prefixes and isolated per-project prefixes boot headlessly with Mono, Gecko, and crash dialogs disabled. Each prefix enforces advisory flock locking, dosdevices/ drive mounts, drive_c symlinks, DLL overrides, registry entries, and automatic drift reconciliation.
  • Built-in toolchain recipes install .NET SDK, portable Windows Python via NuGet .nupkg, Inno Setup, NSIS, and optional winetricks verbs. Generic [toolchains.custom.*] recipes also unpack .zip, .tar.xz, .tar.gz, and .7z archives or run .msi and .exe installers with SHA-256 checks and win7 compatibility warnings.
  • The task runner sorts depends graphs, mixes Wine and host shell commands with MiniJinja templates, applies KEY=VALUE overrides, and checks /proc regex forbid_running guards. It also skips Wine startup on host-only task graphs and executes --all-targets matrices.
  • Generated Nushell completions use extern --strict signatures with explicit input -> output types, @structured [--json] { from json } output decoding, def --wrapped passthrough for run and exec, and local __complete queries.
  • Every Rust subcommand and generated Nushell signature uses long flags (--target, --locked, --verbose, --quiet, --help) with no single-dash aliases.

Installation

Build and install from source with Rust 1.85+:

git clone https://github.com/BeyondMagic/winesmith.git
cd winesmith
cargo install --path .

Check the installed binary and inspect your Linux host environment:

winesmith --version
winesmith doctor

Quick start

You can run single Windows commands immediately or set up a manifest-driven project.

Zero-config ad-hoc commands

Run Windows executables in an isolated or spec-hashed shared prefix without creating winesmith.toml:

winesmith exec --win win7 -- cmd /c ver
winesmith exec --win win10 --toolchain python@3.12.7 -- python.exe --version

Manifest projects

Generate a starter manifest (minimal, dotnet, python, or packaging), provision the environment, and run declared tasks:

winesmith init --template dotnet
winesmith setup
winesmith run build config=Release
winesmith run test
winesmith shell

Configuration layering and winesmith.toml

Configuration values merge across six layers, from lowest to highest priority:

  1. Built-in defaults set win10, win64, display = "none", kron4ek:10.0-staging-amd64-wow64, and prefix.mode = "shared".
  2. User global settings load from ~/.config/winesmith/config.toml, including optional steam_root.
  3. Project configuration loads from the nearest winesmith.toml, searching upward from the working directory.
  4. Machine-local overrides load from winesmith.local.toml next to the manifest.
  5. Environment variables override earlier layers via WINESMITH_RUNNER, WINESMITH_WIN, WINESMITH_ARCH, WINESMITH_DISPLAY, WINESMITH_PREFIX, WINESMITH_STEAM_ROOT, and WINESMITH_VAR_<NAME>.
  6. Command-line flags (--target, --runner, --win, --arch, --display, --gui, --var KEY=VALUE, and positional KEY=VALUE on run) take final precedence.

Example project manifest

This manifest compiles a .NET 8 application, builds an Inno Setup installer with a running-process guard, and supports separate Windows 7 and Windows 11 targets:

[project]
name = "MyWindowsApp"

[windows]
version = "win10"
arch = "win64"
display = "none"
wineserver_persist_secs = 60

[runner]
kind = "kron4ek"
version = "10.0-staging-amd64-wow64"

[prefix]
mode = "shared"
name = "myapp-net8"

[mounts]
w = "."

[vars]
config = "Release"
project = "src/MyApp.csproj"

[toolchains.dotnet]
version = "8.0.415"
shared_nuget_cache = true
tools = ["dotnet-format"]

[toolchains.inno]
version = "6.7.4"

[targets.win7-x86]
windows = { version = "win7", arch = "win32" }

[targets.win11-x64]
windows = { version = "win11", arch = "win64" }

[tasks.build]
description = "Compile Windows application in Wine"
run = "dotnet build {{ winpath(project) }} -c {{ config }}"

[tasks.package]
description = "Build installer and inspect output on Linux host"
depends = ["build"]
forbid_running = ["(?i)MyWindowsApp\\.exe"]
steps = [
  { wine = "ISCC.exe /DConfig={{ config }} {{ winpath('packaging/setup.iss') }}" },
  { host = "ls -lh Output/" }
]

[tasks.clean]
description = "Remove local build directories"
host = "rm -rf src/bin src/obj Output"

Toolchain recipes

Each recipe type installs into drive_c and registers its required Windows environment variables and PATH entries:

  • [toolchains.dotnet] extracts the Microsoft .NET SDK (win-x64 or win-x86) into C:\dotnet, sets DOTNET_ROOT, maps host ~/.nuget/packages when shared_nuget_cache = true, installs templates and global tools, and runs post_install hooks.
  • [toolchains.python] extracts portable Windows Python from NuGet (python or pythonx86) into C:\python, runs ensurepip, sets PYTHONUTF8=1 and PIP_CACHE_DIR, and installs declared packages.
  • [toolchains.inno] installs Inno Setup unattended into C:\tools\inno and exposes ISCC.exe on PATH.
  • [toolchains.nsis] unpacks portable NSIS into C:\tools\nsis and exposes makensis.exe on PATH.
  • [toolchains.custom.<name>] downloads https://, http://, or file:// URLs with optional SHA-256 checks and either unpacks archives to extract_to or runs .msi/.exe installers with installer_args. It also configures path, env, dll_overrides, registry keys, optional winetricks verbs, and Wine or host post_install hooks.

Nushell 0.117+ integration

Install the autoload script to $XDG_CONFIG_HOME/nushell/autoload/winesmith.nu (or pass --path <FILE>):

winesmith completions install nu

Reload Nushell or run source ~/.config/nushell/autoload/winesmith.nu. Query subcommands decode JSON automatically when piped, while winesmith run and winesmith exec forward arbitrary Windows flags and KEY=VALUE overrides through def --wrapped:

winesmith env list | where windows == "win7"
winesmith tasks | select name description
winesmith doctor | get checks | where status != "ok"
winesmith runner detect | get local_protons

CI pipelines and exit codes

Commit winesmith.lock produced by winesmith setup and enforce checksum pinning in CI:

winesmith setup --all-targets --locked
winesmith run build --all-targets --locked config=Release
winesmith doctor --json

The CLI returns distinct exit codes by failure category (propagating child process codes directly on exec and run):

Code Meaning
0 Command succeeded or child process exited with 0.
1 Runtime error, failed download or extraction, failed doctor check, or non-zero child exit code.
2 Invalid CLI flag, missing or invalid winesmith.toml, unknown target or task, or dependency cycle.
3 Missing lockfile under --locked, lockfile drift, or SHA-256 mismatch.
4 Blocked by an active process matching forbid_running.

Development and testing

Run formatting, static analysis, and unit and integration tests locally:

cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test --all-targets
cargo test --test e2e -- --ignored --nocapture

Build the static documentation site under documentation/site/:

cd documentation
zensical build --clean

License

winesmith is licensed under AGPL-3.0-or-later (LICENSE) with a GCC-style Compilation Output Exception under Section 7 (COPYING.EXCEPTION, explained in ADR-002). Compiled binaries, installers, lockfiles, .cmd wrappers, and shell completion scripts generated by running winesmith are excluded from AGPL-3.0 obligations.

About

Compile and package Windows 7, 10, and 11 software on Linux inside reproducible Wine and Proton environments without a virtual machine.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages