|
35 | 35 | }; |
36 | 36 |
|
37 | 37 | rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ]; |
38 | | - |
39 | 38 | rust = pkgs.rust-bin.stable.latest.default.override { |
40 | 39 | targets = [ "wasm32-unknown-unknown" ]; |
41 | 40 | extensions = rustExtensions; |
42 | 41 | }; |
43 | 42 |
|
44 | | - rustNightlyPkg = pkgs.rust-bin.nightly."2025-06-23".default.override { |
| 43 | + rustGPUToolchainPkg = pkgs.rust-bin.nightly."2025-06-23".default.override { |
45 | 44 | extensions = rustExtensions ++ [ "rustc-dev" "llvm-tools" ]; |
46 | 45 | }; |
47 | | - |
48 | | - rustPlatformNightly = pkgs.makeRustPlatform { |
49 | | - cargo = rustNightlyPkg; |
50 | | - rustc = rustNightlyPkg; |
| 46 | + rustGPUToolchainRustPlatform = pkgs.makeRustPlatform { |
| 47 | + cargo = rustGPUToolchainPkg; |
| 48 | + rustc = rustGPUToolchainPkg; |
51 | 49 | }; |
52 | | - |
53 | | - rustc_codegen_spirv = rustPlatformNightly.buildRustPackage (finalAttrs: { |
| 50 | + rustc_codegen_spirv = rustGPUToolchainRustPlatform.buildRustPackage (finalAttrs: { |
54 | 51 | pname = "rustc_codegen_spirv"; |
55 | 52 | version = "0-unstable-2025-08-04"; |
56 | 53 | src = pkgs.fetchFromGitHub { |
|
60 | 57 | hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno="; |
61 | 58 | }; |
62 | 59 | cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4="; |
63 | | - |
64 | 60 | cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-installed-tools" "--no-default-features" ]; |
65 | 61 | doCheck = false; |
66 | 62 | }); |
67 | 63 |
|
68 | | - cargoGpuPkg = rustPlatformNightly.buildRustPackage (finalAttrs: { |
69 | | - pname = "cargo-gpu"; |
70 | | - version = "0-unstable-2025-07-24"; |
71 | | - src = pkgs.fetchFromGitHub { |
72 | | - owner = "Rust-GPU"; |
73 | | - repo = "cargo-gpu"; |
74 | | - rev = "a2ad3574dd32142ff661994e0d79448a45d18f47"; |
75 | | - hash = "sha256-YGu9Cuw+pcN9/rCuCxImouzsQ3ScHF+cW6zgxMm0XGI="; |
76 | | - }; |
77 | | - cargoHash = "sha256-tyad9kO90uwAnMQYa09takIBXifrumSx2C4rpSK95aM="; |
| 64 | + # Wrapper script for running rust commands with the rust toolchain used by rust-gpu. |
| 65 | + # For example `rust-gpu cargo --version` or `rust-gpu rustc --version`. |
| 66 | + execWithRustGPUEnvironment = pkgs.writeShellScriptBin "rust-gpu" '' |
| 67 | + #!${pkgs.lib.getExe pkgs.bash} |
78 | 68 |
|
79 | | - doCheck = false; |
80 | | - }); |
| 69 | + filtered_args=() |
| 70 | + for arg in "$@"; do |
| 71 | + case "$arg" in |
| 72 | + +nightly|+nightly-*) ;; |
| 73 | + *) filtered_args+=("$arg") ;; |
| 74 | + esac |
| 75 | + done |
81 | 76 |
|
82 | | - cargoNightlyPkg = pkgs.writeShellScriptBin "cargo-nightly" '' |
83 | | - #!${pkgs.bash}/bin/bash |
| 77 | + export PATH="${pkgs.lib.makeBinPath [ rustGPUToolchainPkg pkgs.spirv-tools ]}:$PATH" |
| 78 | + export RUSTC_CODEGEN_SPIRV_PATH="${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so" |
84 | 79 |
|
85 | | - exec ${rustNightlyPkg}/bin/cargo $@ |
| 80 | + exec ${"\${filtered_args[@]}"} |
86 | 81 | ''; |
87 | 82 |
|
88 | | - |
89 | 83 | libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: { |
90 | 84 | version = "139.0.17"; |
91 | 85 | gitRevision = "6c347eb"; |
|
98 | 92 | strip $out/lib/* |
99 | 93 | ''; |
100 | 94 | }); |
101 | | - |
102 | 95 | libcefPath = pkgs.runCommand "libcef-path" {} '' |
103 | 96 | mkdir -p $out |
104 | 97 |
|
|
145 | 138 | # Linker |
146 | 139 | pkgs.mold |
147 | 140 |
|
148 | | - pkgs.spirv-tools |
149 | | - cargoNightlyPkg |
150 | | - cargoGpuPkg |
| 141 | + execWithRustGPUEnvironment |
151 | 142 | ]; |
152 | 143 | # Development tools that don't need to be in LD_LIBRARY_PATH |
153 | 144 | devTools = with pkgs; [ |
|
170 | 161 | CEF_PATH = libcefPath; |
171 | 162 | XDG_DATA_DIRS="${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}:${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}:$XDG_DATA_DIRS"; |
172 | 163 |
|
173 | | - RUSTC_CODEGEN_SPIRV="${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so"; |
174 | | - |
175 | 164 | shellHook = '' |
176 | 165 | alias cargo='mold --run cargo' |
177 | 166 | ''; |
|
0 commit comments