From e0a6938475a85d1134b15fc5adae3704345315ad Mon Sep 17 00:00:00 2001 From: gtb-sbe <361163825+gtb-sbe@users.noreply.github.com> Date: Wed, 25 Nov 2026 18:27:30 +0100 Subject: [PATCH 1/2] nix: add a development shell --- .envrc | 1 + .gitignore | 1 + examples/lanes/README.md | 1 + flake.lock | 82 ++++++++++++++++++++++++++++++++++++++++ flake.nix | 57 ++++++++++++++++++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 390f766c..fa37ec97 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ __pycache__/ *.appx *.msix *.dmp +.direnv diff --git a/examples/lanes/README.md b/examples/lanes/README.md index 6844d231..9d11262a 100644 --- a/examples/lanes/README.md +++ b/examples/lanes/README.md @@ -7,6 +7,7 @@ Lanes is an original, turn-based homebrew game for Project TuxBox. Collect as ma Use an x86-64 PC with Python 3.10 or newer, Rust 1.95 or newer with Cargo, and the DirectX Shader Compiler (`dxc`) on your PATH. Add the Windows build target once with `rustup target add x86_64-pc-windows-msvc`. [DirectX Shader Compiler releases](https://github.com/microsoft/DirectXShaderCompiler/releases) - **Linux** needs `clang-cl`, `lld-link` and the Windows SDK and C runtime staged with xwin. To stage them in the cargo-xwin cache that `build.py` reads, run `cargo install cargo-xwin` and then `cargo xwin cache xwin --xwin-arch x86_64` once. If the SDK is outside the cargo-xwin cache, set `XWIN_SDK_ROOT` to the directory containing `sdk/` and `crt/`. The launcher builds a small Vulkan layer on first run, so also install the Vulkan headers (`vulkan-headers` on Arch). Use Microsoft's Linux DXC release: Arch's `directx-shader-compiler` 1.10.2605.37 aborts on every shader, and `build.py` reports this before building. Install UMU (`umu-run`, the `umu-launcher` package in the AUR on Arch) and Proton Experimental to play. From the project folder, run `python3 -m venv .venv` and `source .venv/bin/activate` before installing the Python dependencies. +- **Nix** users can run `nix develop` (or `direnv allow`) for a shell with these Linux tools. The Windows SDK still needs `cargo xwin cache xwin --xwin-arch x86_64` once, and Proton Experimental comes from Steam. - **Windows** needs Visual Studio Build Tools with the C++ tools and Windows SDK. Run the commands in an **x64 Native Tools Command Prompt**. ## Build and play diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..7e4b86ed --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1794427683, + "narHash": "sha256-o7ey9gEilsxaifqJWnBDlYSKbNWYQYtKwDyXeZU2kaU=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cd489559845d81f673a12885576016c65cbe9363", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1795234589, + "narHash": "sha256-f/VVvxf5RsQgWVhUtefoca5ktVg0DA2bnkMOcmSnozo=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2786a2a72088ecf32aea5b3ec52099e6a7cff78f", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1795604585, + "narHash": "sha256-rsB/BPQf+Q9p7O7WhqtmG64b3F175ly7swafxWS1etM=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "67021b279bfffe654a0201ede805748a255ae5a7", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1791244623, + "narHash": "sha256-uuanbkFk8a313Zfrxdcz8Us/yQtaxNnKJtX8v0ZPpd8=", + "owner": "nix-systems", + "repo": "default", + "rev": "d36eeed142f88b5a636f2e3856a53c61654cf29b", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..ef7f8725 --- /dev/null +++ b/flake.nix @@ -0,0 +1,57 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + nixpkgs, + flake-utils, + rust-overlay, + ... + }: + flake-utils.lib.eachSystem ["x86_64-linux"] (system: let + pkgs = import nixpkgs { + inherit system; + overlays = [rust-overlay.overlays.default]; + }; + + rust = pkgs.rust-bin.stable."1.95.0".default.override { + extensions = ["rust-src" "rust-analyzer"]; + targets = ["x86_64-unknown-linux-gnu" "x86_64-pc-windows-msvc"]; + }; + + tools = with pkgs; [ + # Languages + rust + (python312.withPackages (ps: [ps.pefile])) + + # Windows PE toolchain (clang-cl is only in the unwrapped package) + llvmPackages.clang-unwrapped + llvmPackages.lld + llvmPackages.llvm + cargo-xwin + directx-shader-compiler + + # Launcher and GPU checks + umu-launcher + bubblewrap + xvfb-run + mangohud + zenity + ]; + in { + devShells.default = pkgs.mkShell { + packages = tools; + buildInputs = [pkgs.lz4]; + + # Python loads liblz4 through ctypes + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [pkgs.lz4]; + VULKAN_HEADERS_INCLUDE = "${pkgs.vulkan-headers}/include"; + }; + }); +} From b4385b63d30ad6c189e60795ef1629392d0d8cd3 Mon Sep 17 00:00:00 2001 From: gtb-sbe <361163825+gtb-sbe@users.noreply.github.com> Date: Wed, 25 Nov 2026 20:28:04 +0100 Subject: [PATCH 2/2] nix: run the GPU checks from the development shell --- examples/lanes/README.md | 2 +- flake.nix | 49 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/examples/lanes/README.md b/examples/lanes/README.md index 9590be49..2c5ab88e 100644 --- a/examples/lanes/README.md +++ b/examples/lanes/README.md @@ -7,7 +7,7 @@ Lanes is an original, turn-based homebrew game for Project TuxBox. Collect as ma Use an x86-64 PC with Python 3.10 or newer, Rust 1.95 or newer with Cargo, and the DirectX Shader Compiler (`dxc`) on your PATH. Add the Windows build target once with `rustup target add x86_64-pc-windows-msvc`. [DirectX Shader Compiler releases](https://github.com/microsoft/DirectXShaderCompiler/releases) - **Linux** needs `clang-cl`, `lld-link` and the Windows SDK and C runtime staged with xwin. To stage them in the cargo-xwin cache that `build.py` reads, run `cargo install cargo-xwin` and then `cargo xwin cache xwin --xwin-arch x86_64` once. If the SDK is outside the cargo-xwin cache, set `XWIN_SDK_ROOT` to the directory containing `sdk/` and `crt/`. The launcher builds a small Vulkan layer on first run, so also install the Vulkan headers (`vulkan-headers` on Arch). Use Microsoft's Linux DXC release: Arch's `directx-shader-compiler` 1.10.2605.37 aborts on every shader, and `build.py` reports this before building. Install UMU (`umu-run`, the `umu-launcher` package in the AUR on Arch) and Proton Experimental to play. From the project folder, run `python3 -m venv .venv` and `source .venv/bin/activate` before installing the Python dependencies. -- **Nix** users can run `nix develop` (or `direnv allow`) for a shell with these Linux tools. The Windows SDK still needs `cargo xwin cache xwin --xwin-arch x86_64` once, and Proton Experimental comes from Steam. +- **Nix** users can run `nix develop` (or `direnv allow`) for a shell with these Linux tools. The Windows SDK still needs `cargo xwin cache xwin --xwin-arch x86_64` once, and Proton Experimental comes from Steam. On NixOS, prefix the GPU checks with `tuxbox-fhs` (`tuxbox-fhs python tuxbox.py check ...`), which supplies the system libraries that Proton's Wine expects. - **Windows** needs Visual Studio Build Tools with the C++ tools and Windows SDK. Run the commands in an **x64 Native Tools Command Prompt**. ## Build and play diff --git a/flake.nix b/flake.nix index ef7f8725..3d0b19de 100644 --- a/flake.nix +++ b/flake.nix @@ -41,16 +41,59 @@ umu-launcher bubblewrap xvfb-run + xwayland mangohud zenity ]; + + # The isolated GPU checks start Proton's Wine directly, without umu's runtime + fhs = pkgs.buildFHSEnv { + name = "tuxbox-fhs"; + targetPkgs = _: tools ++ [pkgs.stdenv.cc]; + # Proton's 64-bit and 32-bit Wine + multiArch = true; + multiPkgs = p: + with p; [ + alsa-lib + fontconfig + freetype + gnutls + libGL + libpulseaudio + libx11 + libxcb + libxcomposite + libxcursor + libxext + libxfixes + libxi + libxinerama + libxkbcommon + libxrandr + libxrender + libxxf86vm + lz4 + systemd + vulkan-loader + wayland + zlib + ]; + profile = '' + export VULKAN_HEADERS_INCLUDE=${pkgs.vulkan-headers}/include + # The checks mount an empty /tmp, so nix develop's TMPDIR would not exist + export TMPDIR=/tmp TMP=/tmp TEMP=/tmp + # 32-bit preloads such as Steam's extest fail in 64-bit processes + unset LD_PRELOAD + ''; + runScript = "env"; + }; in { devShells.default = pkgs.mkShell { - packages = tools; + packages = tools ++ [fhs]; buildInputs = [pkgs.lz4]; - # Python loads liblz4 through ctypes - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [pkgs.lz4]; + # Python loads these through ctypes + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [pkgs.lz4 pkgs.libx11]; VULKAN_HEADERS_INCLUDE = "${pkgs.vulkan-headers}/include"; }; });