mistral-rs: make free again, refactor (#398403)

authored by Someone and committed by GitHub aaa5b43a 270ec701

+9 -9
+9 -9
pkgs/by-name/mi/mistral-rs/package.nix
··· 34 34 }: 35 35 36 36 let 37 + inherit (stdenv) hostPlatform; 38 + 37 39 accelIsValid = builtins.elem acceleration [ 38 40 null 39 41 false ··· 67 69 metalSupport = 68 70 assert accelIsValid; 69 71 (acceleration == "metal") 70 - || (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64 && (acceleration == null)); 72 + || (hostPlatform.isDarwin && hostPlatform.isAarch64 && (acceleration == null)); 71 73 72 74 in 73 75 rustPlatform.buildRustPackage (finalAttrs: { ··· 119 121 buildFeatures = 120 122 lib.optionals cudaSupport [ "cuda" ] 121 123 ++ lib.optionals mklSupport [ "mkl" ] 122 - ++ lib.optionals (stdenv.hostPlatform.isDarwin && metalSupport) [ "metal" ]; 124 + ++ lib.optionals (hostPlatform.isDarwin && metalSupport) [ "metal" ]; 123 125 124 126 env = 125 127 { ··· 149 151 CUDA_TOOLKIT_ROOT_DIR = lib.getDev cudaPackages.cuda_cudart; 150 152 }); 151 153 152 - appendRunpaths = [ 154 + appendRunpaths = lib.optionals cudaSupport [ 153 155 (lib.makeLibraryPath [ 154 156 cudaPackages.libcublas 155 157 cudaPackages.libcurand ··· 159 161 # swagger-ui will once more be copied in the target directory during the check phase 160 162 # Not deleting the existing unpacked archive leads to a `PermissionDenied` error 161 163 preCheck = '' 162 - rm -rf target/${stdenv.hostPlatform.config}/release/build/ 164 + rm -rf target/${hostPlatform.config}/release/build/ 163 165 ''; 164 166 165 167 # Prevent checkFeatures from inheriting buildFeatures because ··· 185 187 tests = { 186 188 version = testers.testVersion { package = mistral-rs; }; 187 189 188 - withMkl = lib.optionalAttrs (stdenv.hostPlatform == "x86_64-linux") ( 190 + withMkl = lib.optionalAttrs (hostPlatform.isLinux && hostPlatform.isx86_64) ( 189 191 mistral-rs.override { acceleration = "mkl"; } 190 192 ); 191 - withCuda = lib.optionalAttrs stdenv.hostPlatform.isLinux ( 192 - mistral-rs.override { acceleration = "cuda"; } 193 - ); 194 - withMetal = lib.optionalAttrs (stdenv.hostPlatform == "aarch64-darwin") ( 193 + withCuda = lib.optionalAttrs hostPlatform.isLinux (mistral-rs.override { acceleration = "cuda"; }); 194 + withMetal = lib.optionalAttrs (hostPlatform.isDarwin && hostPlatform.isAarch64) ( 195 195 mistral-rs.override { acceleration = "metal"; } 196 196 ); 197 197 };