Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ __pycache__/
*.appx
*.msix
*.dmp
.direnv
1 change: 1 addition & 0 deletions examples/lanes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [GE-Proton11-14](https://github.com/GloriousEggroll/proton-ge-custom/releases/tag/GE-Proton11-14), extracted into Steam's `compatibilitytools.d`, 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. 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
Expand Down
82 changes: 82 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 100 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
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
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 ++ [fhs];
buildInputs = [pkgs.lz4];

# Python loads these through ctypes
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [pkgs.lz4 pkgs.libx11];
VULKAN_HEADERS_INCLUDE = "${pkgs.vulkan-headers}/include";
};
});
}
Loading