|
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-AFt3Nc+NqK8DxNUhDBcOUmk3XDVcoToVeFIMYNszdbY="; |
61 | 58 | }; |
62 | 59 | cargoHash = "sha256-en3BYJWQabH064xeAwYQrvcr6EuWg/QjvsG+Jd6HHCk"; |
63 | | - |
64 | 60 | cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-installed-tools" "--no-default-features" ]; |
65 | | - |
66 | 61 | doCheck = false; |
67 | 62 | }); |
68 | 63 |
|
69 | | - cargoGpuPkg = rustPlatformNightly.buildRustPackage (finalAttrs: { |
70 | | - pname = "cargo-gpu"; |
71 | | - version = "0-unstable-2025-07-24"; |
72 | | - src = pkgs.fetchFromGitHub { |
73 | | - owner = "Rust-GPU"; |
74 | | - repo = "cargo-gpu"; |
75 | | - rev = "a2ad3574dd32142ff661994e0d79448a45d18f47"; |
76 | | - hash = "sha256-YGu9Cuw+pcN9/rCuCxImouzsQ3ScHF+cW6zgxMm0XGI="; |
77 | | - }; |
78 | | - 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} |
79 | 68 |
|
80 | | - doCheck = false; |
81 | | - }); |
| 69 | + filtered_args=() |
| 70 | + for arg in "$@"; do |
| 71 | + case "$arg" in |
| 72 | + +nightly|+nightly-*) ;; |
| 73 | + *) filtered_args+=("$arg") ;; |
| 74 | + esac |
| 75 | + done |
82 | 76 |
|
83 | | - cargoNightlyPkg = pkgs.writeShellScriptBin "cargo-nightly" '' |
84 | | - #!${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" |
85 | 79 |
|
86 | | - exec ${rustNightlyPkg}/bin/cargo $@ |
| 80 | + exec ${"\${filtered_args[@]}"} |
87 | 81 | ''; |
88 | 82 |
|
89 | | - |
90 | 83 | libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: { |
91 | 84 | version = "139.0.17"; |
92 | 85 | gitRevision = "6c347eb"; |
|
99 | 92 | strip $out/lib/* |
100 | 93 | ''; |
101 | 94 | }); |
102 | | - |
103 | 95 | libcefPath = pkgs.runCommand "libcef-path" {} '' |
104 | 96 | mkdir -p $out |
105 | 97 |
|
|
146 | 138 | # Linker |
147 | 139 | pkgs.mold |
148 | 140 |
|
149 | | - pkgs.spirv-tools |
150 | | - cargoNightlyPkg |
151 | | - cargoGpuPkg |
| 141 | + execWithRustGPUEnvironment |
152 | 142 | ]; |
153 | 143 | # Development tools that don't need to be in LD_LIBRARY_PATH |
154 | 144 | devTools = with pkgs; [ |
|
171 | 161 | CEF_PATH = libcefPath; |
172 | 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"; |
173 | 163 |
|
174 | | - RUSTC_CODEGEN_SPIRV="${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so"; |
175 | | - |
176 | 164 | shellHook = '' |
177 | 165 | alias cargo='mold --run cargo' |
178 | 166 | ''; |
|
0 commit comments