From 83cb45b06fa097f5ff76588a0c19b5dab5c1a600 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 13 Apr 2025 18:07:58 +0200 Subject: [PATCH 1/2] mistral-rs: revert linking CUDA in CPU variant --- pkgs/by-name/mi/mistral-rs/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/mi/mistral-rs/package.nix b/pkgs/by-name/mi/mistral-rs/package.nix index 9903ed90480a..7395fde72228 100644 --- a/pkgs/by-name/mi/mistral-rs/package.nix +++ b/pkgs/by-name/mi/mistral-rs/package.nix @@ -149,7 +149,7 @@ rustPlatform.buildRustPackage (finalAttrs: { CUDA_TOOLKIT_ROOT_DIR = lib.getDev cudaPackages.cuda_cudart; }); - appendRunpaths = [ + appendRunpaths = lib.optionals cudaSupport [ (lib.makeLibraryPath [ cudaPackages.libcublas cudaPackages.libcurand From 8ead8d0157948f90ed1eb6314ca55fbba9eb51ce Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 13 Apr 2025 18:25:14 +0200 Subject: [PATCH 2/2] mistral-rs: refactor use of stdenv.hostPlatform --- pkgs/by-name/mi/mistral-rs/package.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/mi/mistral-rs/package.nix b/pkgs/by-name/mi/mistral-rs/package.nix index 7395fde72228..8def84e252c5 100644 --- a/pkgs/by-name/mi/mistral-rs/package.nix +++ b/pkgs/by-name/mi/mistral-rs/package.nix @@ -34,6 +34,8 @@ }: let + inherit (stdenv) hostPlatform; + accelIsValid = builtins.elem acceleration [ null false @@ -67,7 +69,7 @@ let metalSupport = assert accelIsValid; (acceleration == "metal") - || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 && (acceleration == null)); + || (hostPlatform.isDarwin && hostPlatform.isAarch64 && (acceleration == null)); in rustPlatform.buildRustPackage (finalAttrs: { @@ -119,7 +121,7 @@ rustPlatform.buildRustPackage (finalAttrs: { buildFeatures = lib.optionals cudaSupport [ "cuda" ] ++ lib.optionals mklSupport [ "mkl" ] - ++ lib.optionals (stdenv.hostPlatform.isDarwin && metalSupport) [ "metal" ]; + ++ lib.optionals (hostPlatform.isDarwin && metalSupport) [ "metal" ]; env = { @@ -159,7 +161,7 @@ rustPlatform.buildRustPackage (finalAttrs: { # swagger-ui will once more be copied in the target directory during the check phase # Not deleting the existing unpacked archive leads to a `PermissionDenied` error preCheck = '' - rm -rf target/${stdenv.hostPlatform.config}/release/build/ + rm -rf target/${hostPlatform.config}/release/build/ ''; # Prevent checkFeatures from inheriting buildFeatures because @@ -185,13 +187,11 @@ rustPlatform.buildRustPackage (finalAttrs: { tests = { version = testers.testVersion { package = mistral-rs; }; - withMkl = lib.optionalAttrs (stdenv.hostPlatform == "x86_64-linux") ( + withMkl = lib.optionalAttrs (hostPlatform.isLinux && hostPlatform.isx86_64) ( mistral-rs.override { acceleration = "mkl"; } ); - withCuda = lib.optionalAttrs stdenv.hostPlatform.isLinux ( - mistral-rs.override { acceleration = "cuda"; } - ); - withMetal = lib.optionalAttrs (stdenv.hostPlatform == "aarch64-darwin") ( + withCuda = lib.optionalAttrs hostPlatform.isLinux (mistral-rs.override { acceleration = "cuda"; }); + withMetal = lib.optionalAttrs (hostPlatform.isDarwin && hostPlatform.isAarch64) ( mistral-rs.override { acceleration = "metal"; } ); };