From aaac7c2239b00878cb88029428dfaf9ad79adcaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20de=20Kok?= Date: Wed, 14 Jan 2026 13:19:40 +0100 Subject: [PATCH] Make `build-and-upload` and `kernels` work without applicable build set We usually want the `build-and-upload` and `kernels` commands to work, even when there are no applicable build sets (e.g. when compiling a CUDA kernel on macOS). This makes it easier to integrate these commands into CI (which would otherwise fail). This change makes it so that these commands work without applicable build sets. --- lib/gen-flake-outputs.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/gen-flake-outputs.nix b/lib/gen-flake-outputs.nix index ca3db386..64e312fc 100644 --- a/lib/gen-flake-outputs.nix +++ b/lib/gen-flake-outputs.nix @@ -101,6 +101,16 @@ let else builtins.head buildSetsSorted; shellTorch = bestBuildSet.torch.variant; + # We need a package set for some outputs (e.g. kernels and build-and-upload), + # even when there is no applicable build set. + pkgs = + let + sorted = lib.sort configCompare (addSortOrder buildSets); + in + if sorted == [ ] then + throw "No build set is available for this system" + else + (builtins.head sorted).pkgs; headOrEmpty = l: if l == [ ] then [ ] else [ (builtins.head l) ]; in { @@ -188,11 +198,17 @@ in "repo-id" ] "kernels-community/${buildToml.general.name}" buildToml; branch = lib.attrByPath [ "general" "hub" "branch" ] "main" buildToml; + # `kernels upload` fails when there are no build variants to upload. + # However, we do not want this command to error out in that case, so + # only insert the upload command when there is something to upload. + uploadStr = lib.optionalString (applicableBuildSets != [ ]) '' + ${pkgs.python3.pkgs.kernels}/bin/kernels upload --repo-id ${repo_id} --branch ${branch} ${bundle} + ''; in writeScriptBin "build-and-upload" '' #!/usr/bin/env bash set -euo pipefail - ${bestBuildSet.pkgs.python3.pkgs.kernels}/bin/kernels upload --repo-id ${repo_id} --branch ${branch} ${bundle} + ${uploadStr} ''; ci = @@ -214,7 +230,7 @@ in }; kernels = - bestBuildSet.pkgs.python3.withPackages ( + pkgs.python3.withPackages ( ps: with ps; [ kernel-abi-check kernels