cudaPackages: multiplex builder always provides attributes (#406207)

This commit is contained in:
Connor Baker 2025-05-12 06:38:09 -07:00 committed by GitHub
commit 1a120d440a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 15 deletions

View file

@ -1,13 +1,12 @@
# Shims to mimic the shape of ../modules/generic/manifests/{feature,redistrib}/release.nix # Shims to mimic the shape of ../modules/generic/manifests/{feature,redistrib}/release.nix
{ {
lib,
package, package,
# redistArch :: String # redistArch :: String
# String is "unsupported" if the given architecture is unsupported. # String is "unsupported" if the given architecture is unsupported.
redistArch, redistArch,
}: }:
{ {
featureRelease = lib.optionalAttrs (redistArch != "unsupported") { featureRelease = {
inherit (package) minCudaVersion maxCudaVersion; inherit (package) minCudaVersion maxCudaVersion;
${redistArch}.outputs = { ${redistArch}.outputs = {
lib = true; lib = true;

View file

@ -52,12 +52,20 @@ let
lib.versionAtLeast cudaMajorMinorVersion package.minCudaVersion lib.versionAtLeast cudaMajorMinorVersion package.minCudaVersion
&& lib.versionAtLeast package.maxCudaVersion cudaMajorMinorVersion; && lib.versionAtLeast package.maxCudaVersion cudaMajorMinorVersion;
# Releases for our platform and CUDA version. # FIXME: do this at the module system level
# See ../modules/${pname}/releases/releases.nix propagatePlatforms = lib.mapAttrs (redistArch: lib.map (p: { inherit redistArch; } // p));
# allPackages :: List Package
allPackages = lib.filter satisfiesCudaVersion ( # Releases for all platforms and all CUDA versions.
evaluatedModules.config.${pname}.releases.${redistArch} or [ ] allReleases = propagatePlatforms evaluatedModules.config.${pname}.releases;
);
# Releases for all platforms and our CUDA version.
allReleases' = lib.mapAttrs (_: lib.filter satisfiesCudaVersion) allReleases;
# Packages for all platforms and our CUDA versions.
allPackages = lib.concatLists (lib.attrValues allReleases');
packageOlder = p1: p2: lib.versionOlder p1.version p2.version;
packageSupportedPlatform = p: p.redistArch == redistArch;
# Compute versioned attribute name to be used in this package set # Compute versioned attribute name to be used in this package set
# Patch version changes should not break the build, so we only use major and minor # Patch version changes should not break the build, so we only use major and minor
@ -77,8 +85,15 @@ let
newestPackages newestPackages
// { // {
${majorMinorVersion} = ${majorMinorVersion} =
# Only keep the existing package if it is newer than the one we are considering. # Only keep the existing package if it is newer than the one we are considering or it is supported on the
if existingPackage != null && lib.versionOlder package.version existingPackage.version then # current platform and the one we are considering is not.
if
existingPackage != null
&& (
packageOlder package existingPackage
|| (!packageSupportedPlatform package && packageSupportedPlatform existingPackage)
)
then
existingPackage existingPackage
else else
package; package;
@ -87,9 +102,8 @@ let
in in
# Sort the packages by version so the newest is first. # Sort the packages by version so the newest is first.
# NOTE: builtins.sort requires a strict weak ordering, so we must use versionOlder rather than versionAtLeast. # NOTE: builtins.sort requires a strict weak ordering, so we must use versionOlder rather than versionAtLeast.
lib.sort (p1: p2: lib.versionOlder p2.version p1.version) ( # See https://github.com/NixOS/nixpkgs/commit/9fd753ea84e5035b357a275324e7fd7ccfb1fc77.
lib.attrValues newestForEachMajorMinorVersion lib.sort (lib.flip packageOlder) (lib.attrValues newestForEachMajorMinorVersion);
);
extension = extension =
final: _: final: _:

View file

@ -1,13 +1,12 @@
# Shims to mimic the shape of ../modules/generic/manifests/{feature,redistrib}/release.nix # Shims to mimic the shape of ../modules/generic/manifests/{feature,redistrib}/release.nix
{ {
lib,
package, package,
# redistArch :: String # redistArch :: String
# String is `"unsupported"` if the given architecture is unsupported. # String is `"unsupported"` if the given architecture is unsupported.
redistArch, redistArch,
}: }:
{ {
featureRelease = lib.optionalAttrs (redistArch != "unsupported") { featureRelease = {
inherit (package) cudnnVersion minCudaVersion maxCudaVersion; inherit (package) cudnnVersion minCudaVersion maxCudaVersion;
${redistArch}.outputs = { ${redistArch}.outputs = {
bin = true; bin = true;