From 1f3936cd0c1978d058ed978d07f4630711a921f8 Mon Sep 17 00:00:00 2001 From: Timon Schelling Date: Thu, 7 Aug 2025 20:19:24 +0000 Subject: [PATCH 1/6] nix: Try providing cargo-rust-gpu to nix devs, naga branch --- .nix/flake.nix | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/.nix/flake.nix b/.nix/flake.nix index ba9bd62714..eedb11f48f 100644 --- a/.nix/flake.nix +++ b/.nix/flake.nix @@ -34,11 +34,47 @@ inherit system overlays; }; - rustc-wasm = pkgs.rust-bin.stable.latest.default.override { + rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ]; + + rust = pkgs.rust-bin.stable.latest.default.override { targets = [ "wasm32-unknown-unknown" ]; - extensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ]; + extensions = rustExtensions; + }; + + rustNightlyPkg = pkgs.rust-bin.nightly."2025-06-23".default.override { + extensions = rustExtensions ++ [ "rustc-dev" "llvm-tools" ]; }; + rustPlatformNightly = pkgs.makeRustPlatform { + cargo = rustNightlyPkg; + rustc = rustNightlyPkg; + }; + + rustc_codegen_spirv = (rustPlatformNightly.buildRustPackage.override { + stdenv = pkgs.llvmPackages.stdenv; + }) (finalAttrs: { + pname = "rustc_codegen_spirv"; + version = "0-unstable-2025-08-04"; + src = pkgs.fetchFromGitHub { + owner = "Rust-GPU"; + repo = "rust-gpu"; + rev = "c12f216121820580731440ee79ebc7403d6ea04f"; + hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno="; + }; + cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4="; + + cargoBuildFlags = [ "-p" "rustc_codegen_spirv" ]; + doCheck = false; + }); + + cargoRustGpuBuild = pkgs.writeShellScriptBin "cargo-rust-gpu" '' + #!${pkgs.bash}/bin/bash + + export PATH="${pkgs.lib.makeBinPath [rustNightlyPkg]}" + export RUSTFLAGS="-Zcodegen-backend=${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so" + exec cargo +nightly $@ + ''; + libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: { version = "139.0.17"; gitRevision = "6c347eb"; @@ -85,7 +121,7 @@ # Development tools that don't need to be in LD_LIBRARY_PATH buildTools = [ - rustc-wasm + rust pkgs.nodejs pkgs.nodePackages.npm pkgs.binaryen @@ -97,6 +133,8 @@ # Linker pkgs.mold + + cargoRustGpuBuild ]; # Development tools that don't need to be in LD_LIBRARY_PATH devTools = with pkgs; [ From 2f91852900cf106d9206ad6030857b3520d22a35 Mon Sep 17 00:00:00 2001 From: Timon Schelling Date: Thu, 7 Aug 2025 22:29:18 +0000 Subject: [PATCH 2/6] nix: Try providing cargo-rust-gpu to nix devs 2 --- .nix/flake.nix | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/.nix/flake.nix b/.nix/flake.nix index eedb11f48f..89078730db 100644 --- a/.nix/flake.nix +++ b/.nix/flake.nix @@ -50,9 +50,7 @@ rustc = rustNightlyPkg; }; - rustc_codegen_spirv = (rustPlatformNightly.buildRustPackage.override { - stdenv = pkgs.llvmPackages.stdenv; - }) (finalAttrs: { + rustc_codegen_spirv = rustPlatformNightly.buildRustPackage (finalAttrs: { pname = "rustc_codegen_spirv"; version = "0-unstable-2025-08-04"; src = pkgs.fetchFromGitHub { @@ -63,18 +61,31 @@ }; cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4="; - cargoBuildFlags = [ "-p" "rustc_codegen_spirv" ]; + cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-installed-tools" "--no-default-features" ]; doCheck = false; }); - cargoRustGpuBuild = pkgs.writeShellScriptBin "cargo-rust-gpu" '' + cargoGpuPkg = rustPlatformNightly.buildRustPackage (finalAttrs: { + pname = "cargo-gpu"; + version = "0-unstable-2025-07-24"; + src = pkgs.fetchFromGitHub { + owner = "Rust-GPU"; + repo = "cargo-gpu"; + rev = "a2ad3574dd32142ff661994e0d79448a45d18f47"; + hash = "sha256-YGu9Cuw+pcN9/rCuCxImouzsQ3ScHF+cW6zgxMm0XGI="; + }; + cargoHash = "sha256-tyad9kO90uwAnMQYa09takIBXifrumSx2C4rpSK95aM="; + + doCheck = false; + }); + + cargoNightlyPkg = pkgs.writeShellScriptBin "cargo-nightly" '' #!${pkgs.bash}/bin/bash - export PATH="${pkgs.lib.makeBinPath [rustNightlyPkg]}" - export RUSTFLAGS="-Zcodegen-backend=${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so" - exec cargo +nightly $@ + exec ${rustNightlyPkg}/bin/cargo $@ ''; + libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: { version = "139.0.17"; gitRevision = "6c347eb"; @@ -134,7 +145,9 @@ # Linker pkgs.mold - cargoRustGpuBuild + pkgs.spirv-tools + cargoNightlyPkg + cargoGpuPkg ]; # Development tools that don't need to be in LD_LIBRARY_PATH devTools = with pkgs; [ @@ -157,6 +170,8 @@ CEF_PATH = libcefPath; 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"; + RUSTC_CODEGEN_SPIRV="${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so"; + shellHook = '' alias cargo='mold --run cargo' ''; From 55d18996abd2f92dc8174ac667b50a6706d4ba0f Mon Sep 17 00:00:00 2001 From: Timon Schelling Date: Fri, 8 Aug 2025 18:19:36 +0000 Subject: [PATCH 3/6] nix: Add exec with rust-gpu env script to flake --- .nix/flake.nix | 51 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/.nix/flake.nix b/.nix/flake.nix index 89078730db..6673641c55 100644 --- a/.nix/flake.nix +++ b/.nix/flake.nix @@ -35,22 +35,19 @@ }; rustExtensions = [ "rust-src" "rust-analyzer" "clippy" "cargo" ]; - rust = pkgs.rust-bin.stable.latest.default.override { targets = [ "wasm32-unknown-unknown" ]; extensions = rustExtensions; }; - rustNightlyPkg = pkgs.rust-bin.nightly."2025-06-23".default.override { + rustGPUToolchainPkg = pkgs.rust-bin.nightly."2025-06-23".default.override { extensions = rustExtensions ++ [ "rustc-dev" "llvm-tools" ]; }; - - rustPlatformNightly = pkgs.makeRustPlatform { - cargo = rustNightlyPkg; - rustc = rustNightlyPkg; + rustGPUToolchainRustPlatform = pkgs.makeRustPlatform { + cargo = rustGPUToolchainPkg; + rustc = rustGPUToolchainPkg; }; - - rustc_codegen_spirv = rustPlatformNightly.buildRustPackage (finalAttrs: { + rustc_codegen_spirv = rustGPUToolchainRustPlatform.buildRustPackage (finalAttrs: { pname = "rustc_codegen_spirv"; version = "0-unstable-2025-08-04"; src = pkgs.fetchFromGitHub { @@ -60,32 +57,29 @@ hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno="; }; cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4="; - cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-installed-tools" "--no-default-features" ]; doCheck = false; }); - cargoGpuPkg = rustPlatformNightly.buildRustPackage (finalAttrs: { - pname = "cargo-gpu"; - version = "0-unstable-2025-07-24"; - src = pkgs.fetchFromGitHub { - owner = "Rust-GPU"; - repo = "cargo-gpu"; - rev = "a2ad3574dd32142ff661994e0d79448a45d18f47"; - hash = "sha256-YGu9Cuw+pcN9/rCuCxImouzsQ3ScHF+cW6zgxMm0XGI="; - }; - cargoHash = "sha256-tyad9kO90uwAnMQYa09takIBXifrumSx2C4rpSK95aM="; + # Wrapper script for running rust commands with the rust toolchain used by rust-gpu. + # For example `rust-gpu cargo --version` or `rust-gpu rustc --version`. + execWithRustGPUEnvironment = pkgs.writeShellScriptBin "rust-gpu" '' + #!${pkgs.lib.getExe pkgs.bash} - doCheck = false; - }); + filtered_args=() + for arg in "$@"; do + case "$arg" in + +nightly|+nightly-*) ;; + *) filtered_args+=("$arg") ;; + esac + done - cargoNightlyPkg = pkgs.writeShellScriptBin "cargo-nightly" '' - #!${pkgs.bash}/bin/bash + export PATH="${pkgs.lib.makeBinPath [ rustGPUToolchainPkg pkgs.spirv-tools ]}:$PATH" + export RUSTC_CODEGEN_SPIRV_PATH="${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so" - exec ${rustNightlyPkg}/bin/cargo $@ + exec ${"\${filtered_args[@]}"} ''; - libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: { version = "139.0.17"; gitRevision = "6c347eb"; @@ -98,7 +92,6 @@ strip $out/lib/* ''; }); - libcefPath = pkgs.runCommand "libcef-path" {} '' mkdir -p $out @@ -145,9 +138,7 @@ # Linker pkgs.mold - pkgs.spirv-tools - cargoNightlyPkg - cargoGpuPkg + execWithRustGPUEnvironment ]; # Development tools that don't need to be in LD_LIBRARY_PATH devTools = with pkgs; [ @@ -170,8 +161,6 @@ CEF_PATH = libcefPath; 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"; - RUSTC_CODEGEN_SPIRV="${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so"; - shellHook = '' alias cargo='mold --run cargo' ''; From 16798d27506673d153024340984608e3eccccc86 Mon Sep 17 00:00:00 2001 From: Timon Schelling Date: Fri, 29 Aug 2025 19:21:41 +0200 Subject: [PATCH 4/6] nix: override Path for rust gpu --- .nix/flake.nix | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.nix/flake.nix b/.nix/flake.nix index 6673641c55..e3c2c01d48 100644 --- a/.nix/flake.nix +++ b/.nix/flake.nix @@ -60,10 +60,7 @@ cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-installed-tools" "--no-default-features" ]; doCheck = false; }); - - # Wrapper script for running rust commands with the rust toolchain used by rust-gpu. - # For example `rust-gpu cargo --version` or `rust-gpu rustc --version`. - execWithRustGPUEnvironment = pkgs.writeShellScriptBin "rust-gpu" '' + rustGpuCargo = pkgs.writeShellScriptBin "cargo" '' #!${pkgs.lib.getExe pkgs.bash} filtered_args=() @@ -74,11 +71,9 @@ esac done - export PATH="${pkgs.lib.makeBinPath [ rustGPUToolchainPkg pkgs.spirv-tools ]}:$PATH" - export RUSTC_CODEGEN_SPIRV_PATH="${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so" - - exec ${"\${filtered_args[@]}"} + exec ${rustGPUToolchainPkg}/bin/cargo ${"\${filtered_args[@]}"} ''; + rustGpuPathOverride = "${rustGpuCargo}/bin:${rustGPUToolchainPkg}/bin:${pkgs.spirv-tools}/bin"; libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: { version = "139.0.17"; @@ -137,8 +132,6 @@ # Linker pkgs.mold - - execWithRustGPUEnvironment ]; # Development tools that don't need to be in LD_LIBRARY_PATH devTools = with pkgs; [ @@ -150,6 +143,9 @@ gnuplot samply cargo-flamegraph + + # Useful for rust-gpu debugging + pkgs.spirv-tools ]; in { @@ -161,6 +157,9 @@ CEF_PATH = libcefPath; 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"; + RUST_GPU_PATH_OVERRIDE = rustGpuPathOverride; + RUSTC_CODEGEN_SPIRV_PATH = "${rustc_codegen_spirv}/lib/librustc_codegen_spirv.so"; + shellHook = '' alias cargo='mold --run cargo' ''; From 0bdc23df8d488e878c6240a05c893a96c3d174af Mon Sep 17 00:00:00 2001 From: firestar99 Date: Sat, 30 Aug 2025 14:09:33 +0200 Subject: [PATCH 5/6] nix: rust-gpu with `use-compiled-tools` to fix differences --- .nix/flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.nix/flake.nix b/.nix/flake.nix index e3c2c01d48..c5f3e932d3 100644 --- a/.nix/flake.nix +++ b/.nix/flake.nix @@ -57,7 +57,7 @@ hash = "sha256-rG1cZvOV0vYb1dETOzzbJ0asYdE039UZImobXZfKIno="; }; cargoHash = "sha256-AEigcEc5wiBd3zLqWN/2HSbkfOVFneAqNvg9HsouZf4="; - cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-installed-tools" "--no-default-features" ]; + cargoBuildFlags = [ "-p" "rustc_codegen_spirv" "--features=use-compiled-tools" "--no-default-features" ]; doCheck = false; }); rustGpuCargo = pkgs.writeShellScriptBin "cargo" '' @@ -73,7 +73,7 @@ exec ${rustGPUToolchainPkg}/bin/cargo ${"\${filtered_args[@]}"} ''; - rustGpuPathOverride = "${rustGpuCargo}/bin:${rustGPUToolchainPkg}/bin:${pkgs.spirv-tools}/bin"; + rustGpuPathOverride = "${rustGpuCargo}/bin:${rustGPUToolchainPkg}/bin"; libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: { version = "139.0.17"; From a8dc76462946f2ca29c72a09a13721bc623e84ba Mon Sep 17 00:00:00 2001 From: firestar99 Date: Sat, 30 Aug 2025 15:50:18 +0200 Subject: [PATCH 6/6] nix: remove spirv-tools --- .nix/flake.nix | 3 --- 1 file changed, 3 deletions(-) diff --git a/.nix/flake.nix b/.nix/flake.nix index c5f3e932d3..03539534e7 100644 --- a/.nix/flake.nix +++ b/.nix/flake.nix @@ -143,9 +143,6 @@ gnuplot samply cargo-flamegraph - - # Useful for rust-gpu debugging - pkgs.spirv-tools ]; in {