diff --git a/pkgs/development/python-modules/xgrammar/default.nix b/pkgs/development/python-modules/xgrammar/default.nix index 6a1a1549293fd..8ada40b95593d 100644 --- a/pkgs/development/python-modules/xgrammar/default.nix +++ b/pkgs/development/python-modules/xgrammar/default.nix @@ -11,14 +11,13 @@ scikit-build-core, # dependencies - mlx-lm, pydantic, sentencepiece, tiktoken, torch, transformers, triton, - + mlx-lm, # tests pytestCheckHook, writableTmpDirAsHomeHook, @@ -56,22 +55,20 @@ buildPythonPackage rec { torch transformers ] - ++ lib.optionals (stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86_64) [ - triton - ] - ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ - mlx-lm - ]; + ++ lib.optional (lib.meta.availableOn stdenv.hostPlatform triton) triton + ++ lib.optional (lib.meta.availableOn stdenv.hostPlatform mlx-lm) mlx-lm; nativeCheckInputs = [ pytestCheckHook writableTmpDirAsHomeHook ]; - NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isLinux (toString [ - # xgrammar hardcodes -flto=auto while using static linking, which can cause linker errors without this additional flag. - "-ffat-lto-objects" - ]); + NIX_CFLAGS_COMPILE = toString ( + lib.optionals stdenv.cc.isGNU [ + # xgrammar hardcodes -flto=auto while using static linking, which can cause linker errors without this additional flag. + "-ffat-lto-objects" + ] + ); disabledTests = [ # You are trying to access a gated repo.