Repository navigation
Expand file tree
/
Copy pathshell.nix
More file actions
95 lines (81 loc) · 2.87 KB
/
Copy pathshell.nix
File metadata and controls
95 lines (81 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# shell.nix - Development environment for Steam Controller Auto-Charge
#
# Provides all system dependencies needed to build the Rust WASM object
# detection CNN module and run the Vite dev server.
#
# Usage: nix-shell
# This drops you into a shell with:
# - Rust toolchain (stable) with wasm32-unknown-unknown target
# - wasm-pack for building Rust -> WASM packages
# - Node.js 20+ for the Vite frontend
# - pkg-config and OpenSSL (needed by some Rust crates)
#
# The WASM module lives in src/wasm-object-detect/ and is built with:
# cd src/wasm-object-detect && wasm-pack build --target web --out-dir ../wasm-pkg
#
# Then run the Vite dev server:
# npm install && npm run dev
{ pkgs ? import <nixpkgs> { config = { allowUnfree = true; }; } }:
pkgs.mkShell {
buildInputs = with pkgs; [
# --- Rust toolchain ---
# Stable Rust compiler, cargo, and standard library
(python3.withPackages (ps: with ps; [
torchWithRocm
numpy
pillow
onnx
onnxscript
]))
rustc
cargo
rustfmt
clippy
# wasm-pack: builds Rust crates into WASM packages with JS bindings
wasm-pack
# wasm-bindgen-cli: generates JS/TS glue code for wasm-bindgen
wasm-bindgen-cli
# binaryen: wasm-opt for optimizing WASM output size
binaryen
# lld: LLVM linker required for linking wasm32 binaries
lld
git-lfs # models are big
# --- Node.js ---
# Node 24+ LTS for Vite dev server and test runner
nodejs_24
tsx
# --- System libraries ---
# pkg-config: helps Cargo find native libraries
pkg-config
# OpenSSL: required by some Rust networking crates (transitive dep)
openssl
# --- Playwright support ---
playwright-driver
playwright
# --- AMD GPU / WebGPU dependencies ---
vulkan-loader
libGL
mesa.drivers
];
# Set up the Rust WASM target on shell entry
shellHook = ''
# Export Vulkan/GL library path for Chromium/Playwright GPU access
export LD_LIBRARY_PATH="${pkgs.vulkan-loader}/lib:${pkgs.libGL}/lib:/run/opengl-driver/lib:$LD_LIBRARY_PATH"
# Add wasm32 target if not already installed
rustup target add wasm32-unknown-unknown 2>/dev/null || true
# Playwright configuration for NixOS
export PLAYWRIGHT_BROWSERS_PATH="${pkgs.playwright-driver.browsers}"
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
export PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH="${pkgs.playwright-driver.browsers}/chromium-1217/chrome-linux/chrome"
echo ""
echo "🎮 Steam Controller Auto-Charge Dev Environment"
echo " Rust $(rustc --version | cut -d' ' -f2)"
echo " Node $(node --version)"
echo " wasm-pack $(wasm-pack --version 2>/dev/null | cut -d' ' -f2)"
echo ""
echo "Build WASM: cd src/wasm-object-detect && wasm-pack build --target web --out-dir ../wasm-pkg"
echo "Dev server: npm run dev"
echo "Run tests: npm test"
echo ""
'';
}