mirror of
https://github.com/DoubleGhosty/cool_fox.git
synced 2026-12-06 08:38:35 +00:00
nix: dev shell for building the Windows executable on NixOS
This commit is contained in:
19
.github/workflows/ci.yml
vendored
19
.github/workflows/ci.yml
vendored
@ -32,6 +32,25 @@ jobs:
|
||||
- name: Tests
|
||||
run: cargo test --workspace --locked
|
||||
|
||||
# The flake's dev shell and the portable crates through it: keeps the NixOS
|
||||
# instructions honest and catches a stale flake.lock.
|
||||
nix:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: cachix/install-nix-action@v32
|
||||
with:
|
||||
extra_nix_config: |
|
||||
experimental-features = nix-command flakes
|
||||
extra-substituters = https://nix-community.cachix.org
|
||||
extra-trusted-public-keys = nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=
|
||||
- name: Dev shell and platform-independent tests
|
||||
run: >-
|
||||
nix develop --command cargo test --locked
|
||||
-p victory-core -p victory-formats -p victory-pipeline
|
||||
-p victory-shader -p victory-game -p xtask
|
||||
|
||||
# The crates that do not need Windows or D3D12, tested on Linux: a quicker
|
||||
# signal, and a check that they stay portable. victory-pe is left out
|
||||
# because its tests parse their own test executable as a PE image.
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -79,6 +79,10 @@ validate_*.txt
|
||||
*.swp
|
||||
Thumbs.db
|
||||
.DS_Store
|
||||
.direnv/
|
||||
# `nix build` / `nix develop` result symlinks
|
||||
/result
|
||||
/result-*
|
||||
|
||||
# Play-session logs written by the Play-VIctory*.cmd launchers
|
||||
/logs/
|
||||
|
||||
@ -96,6 +96,9 @@ cd cool_fox
|
||||
cargo build --release --locked -p victory
|
||||
```
|
||||
|
||||
On Linux (including NixOS), victory is cross-built with `cargo xwin` and run under
|
||||
Proton or Wine; see [docs/linux.md](docs/linux.md).
|
||||
|
||||
On **Windows 10**, build with the D3D12 Agility SDK instead. Windows 10's own D3D12 has
|
||||
no shader model 6.6 bindless heaps, and root signatures then fail with `0x80070057`:
|
||||
|
||||
|
||||
@ -52,14 +52,17 @@ What it took, in the order it was found (each in its own code comment):
|
||||
|
||||
- **The NVIDIA driver from RPM Fusion** (`akmod-nvidia`), not nouveau.
|
||||
vkd3d-proton needs shader model 6.6 and mesh shaders, which it gets from the
|
||||
proprietary driver's Vulkan.
|
||||
proprietary driver's Vulkan. On NixOS use `hardware.nvidia` (with
|
||||
`nixpkgs.config.allowUnfree`) instead.
|
||||
- **umu-launcher**, to run Windows programs under Proton outside Steam. It is not
|
||||
in Fedora's own repositories: take it from its GitHub releases. With
|
||||
`PROTONPATH=GE-Proton` (the script's default) it downloads GE-Proton itself.
|
||||
For Steam's Proton instead, see step 4.
|
||||
- **Your own complete dump of the title**, outside this checkout.
|
||||
|
||||
## 2. Build victory.exe on Fedora
|
||||
## 2. Build victory.exe
|
||||
|
||||
### Fedora
|
||||
|
||||
```sh
|
||||
sudo dnf install clang llvm # clang-cl and llvm-lib for C parts of dependencies
|
||||
@ -78,6 +81,32 @@ For the diagnostics build (log lines, F3 panel, frame recording):
|
||||
`cargo xwin build --locked --profile diag -p victory --features diagnostics --target x86_64-pc-windows-msvc`,
|
||||
then point `VICTORY_EXE` at `target/x86_64-pc-windows-msvc/diag/victory.exe`.
|
||||
|
||||
### NixOS
|
||||
|
||||
The repository ships a flake with the pinned toolchain, `cargo-xwin`, clang and
|
||||
LLVM/lld:
|
||||
|
||||
```sh
|
||||
nix develop # or: direnv allow
|
||||
cargo xwin build --release --locked -p victory --target x86_64-pc-windows-msvc
|
||||
```
|
||||
|
||||
The flake reads `rust-toolchain.toml`, so the channel, components and
|
||||
`x86_64-pc-windows-msvc` target match the other platforms. `cargo-xwin` downloads
|
||||
the Windows SDK and CRT into `~/.cache/cargo-xwin` on first use (they come under
|
||||
Microsoft's license); the shell's own packages are pure Nix.
|
||||
|
||||
The platform-independent crates test natively:
|
||||
|
||||
```sh
|
||||
cargo test --locked -p victory-core -p victory-formats -p victory-pipeline \
|
||||
-p victory-shader -p victory-game -p xtask
|
||||
```
|
||||
|
||||
To run the executable, take `umu-launcher` from nixpkgs (`nix shell
|
||||
nixpkgs#umu-launcher`, or add it to `environment.systemPackages`) and use
|
||||
`scripts/play-proton.sh` as below.
|
||||
|
||||
## 3. Start it
|
||||
|
||||
```sh
|
||||
|
||||
48
flake.lock
generated
Normal file
48
flake.lock
generated
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1795911899,
|
||||
"narHash": "sha256-OKvZpNQnLc24N/vuklyiHDYmFT4ZQRb5b3Rovh1/Hkg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e713fda5ec9fad59317d86214b1ee646a11896ea",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1796037704,
|
||||
"narHash": "sha256-RPXxaeH+QYru3gHcECgrhECLiFpFBjnzrg+/bXbpNQQ=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "b444040d9bdb292abbd223922d24d57f7ee8b7cd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
47
flake.nix
Normal file
47
flake.nix
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
description = "VIctory — build the Windows executable on NixOS";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
...
|
||||
}:
|
||||
let
|
||||
# The only supported development platform: the toolchain in
|
||||
# rust-toolchain.toml cross-builds x86_64-pc-windows-msvc.
|
||||
system = "x86_64-linux";
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ (import rust-overlay) ];
|
||||
};
|
||||
in
|
||||
{
|
||||
devShells.${system}.default = pkgs.mkShellNoCC {
|
||||
packages = with pkgs; [
|
||||
# Same channel, components and windows target as rustup would use.
|
||||
(rust-bin.fromRustupToolchainFile ./rust-toolchain.toml)
|
||||
# The Fedora instructions in docs/linux.md, in one shell:
|
||||
# cargo-xwin fetches the Windows SDK/CRT into ~/.cache/cargo-xwin.
|
||||
cargo-xwin
|
||||
clang
|
||||
llvm
|
||||
lld
|
||||
git
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
echo "VIctory: cargo xwin build --release --locked -p victory --target x86_64-pc-windows-msvc"
|
||||
echo "Tests: cargo test --locked -p victory-core -p victory-formats -p victory-pipeline -p victory-shader -p victory-game -p xtask"
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -16,6 +16,8 @@ const MAX_ENCODED_RUN: usize = 512;
|
||||
|
||||
const ALLOWED_EXTENSIONS: &[&str] = &[
|
||||
"rs", "toml", "md", "txt", "lock", "yml", "yaml", "json", "hlsl", "hlsli", "ps1", "cmd", "sh",
|
||||
// NixOS development shell (flake.nix).
|
||||
"nix",
|
||||
// Source patches for host tools (patches/), held to the same size and
|
||||
// encoded-run checks as the rest.
|
||||
"patch", "diff",
|
||||
@ -24,6 +26,7 @@ const ALLOWED_NAMES: &[&str] = &[
|
||||
".gitignore",
|
||||
".gitattributes",
|
||||
".editorconfig",
|
||||
".envrc",
|
||||
".victory-root",
|
||||
"pre-commit",
|
||||
"LICENSE",
|
||||
|
||||
Reference in New Issue
Block a user