#!/usr/bin/env bash # Source this to put the pinned no-sudo i686-w64-mingw32 cross toolchain + wine on PATH. # See toolchain.lock for exact provenance (nixpkgs rev, package versions, store paths). # # Must be SOURCED, not executed: `source ./activate.sh` or `. ./activate.sh`. # On success it returns 0 with every required tool on PATH. On failure (toolchain # not installed / nix profile not sourced) it prints recovery guidance and # returns/exits non-zero instead of silently succeeding. _activate_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$HOME/.nix-profile/etc/profile.d/nix.sh" 2>/dev/null || true # Worktree-local bin/ comes first so the unprefixed `dlltool` (and other # aliases below) resolve even though the nix package only installs the # target-prefixed `i686-w64-mingw32-dlltool`. export PATH="$HOME/.nix-profile/bin:$_activate_dir/bin:$PATH" mkdir -p "$_activate_dir/bin" 2>/dev/null || true if command -v i686-w64-mingw32-dlltool >/dev/null 2>&1; then ln -sf "$(command -v i686-w64-mingw32-dlltool)" "$_activate_dir/bin/dlltool" 2>/dev/null || true fi if command -v gendef >/dev/null 2>&1; then ln -sf "$(command -v gendef)" "$_activate_dir/bin/gendef" 2>/dev/null || true fi if command -v i686-w64-mingw32-objdump >/dev/null 2>&1; then ln -sf "$(command -v i686-w64-mingw32-objdump)" "$_activate_dir/bin/objdump" 2>/dev/null || true fi _activate_missing=() for _activate_tool in i686-w64-mingw32-gcc i686-w64-mingw32-g++ gendef dlltool wine; do command -v "$_activate_tool" >/dev/null 2>&1 || _activate_missing+=("$_activate_tool") done if [ "${#_activate_missing[@]}" -gt 0 ]; then { echo "activate.sh: required toolchain tool(s) not found on PATH: ${_activate_missing[*]}" echo " Recovery:" echo " 1. source ~/.nix-profile/etc/profile.d/nix.sh (user-space nix, no sudo)" echo " 2. install the pinned profile recorded in $_activate_dir/toolchain.lock," echo " e.g. for nixpkgs rev 619c39f6eac5d1ed6b8f073a9414baf7034b2356:" echo " NIX_CONFIG=\"extra-experimental-features = nix-command flakes\" \\" echo " nix profile install github:NixOS/nixpkgs/619c39f6eac5d1ed6b8f073a9414baf7034b2356#pkgsCross.mingw32.buildPackages.binutils" echo " (see toolchain.lock for the full ordered install command list)" echo " 3. re-source this file: source $_activate_dir/activate.sh" } >&2 unset _activate_dir _activate_missing _activate_tool return 1 2>/dev/null || exit 1 fi unset _activate_dir _activate_missing _activate_tool