Merge pull request #282185 from SomeoneSerge/fix/cu-multiplex

cudaPackages: fix version solving (again)

Unbreaks tensorflowWithCuda and cudaPackagesGoogle.cudnn_8_6

authored by Someone and committed by GitHub 0689dd2c e7120ab3

+21 -10
+5 -1
pkgs/development/cuda-modules/generic-builders/manifest.nix
··· 47 47 # The redistArch is the name of the architecture for which the redistributable is built. 48 48 # It is `"unsupported"` if the redistributable is not supported on the target platform. 49 49 redistArch = flags.getRedistArch hostPlatform.system; 50 + 51 + sourceMatchesHost = flags.getNixSystem redistArch == stdenv.hostPlatform.system; 50 52 in 51 53 backendStdenv.mkDerivation ( 52 54 finalAttrs: { ··· 136 138 # badPlatformsConditions :: AttrSet Bool 137 139 # Sets `meta.badPlatforms = meta.platforms` if any of the conditions are true. 138 140 # Example: Broken on a specific architecture when some condition is met (like targeting Jetson). 139 - badPlatformsConditions = { }; 141 + badPlatformsConditions = { 142 + "No source" = !sourceMatchesHost; 143 + }; 140 144 141 145 # src :: Optional Derivation 142 146 src = trivial.pipe redistArch [
+16 -9
pkgs/development/cuda-modules/generic-builders/multiplex.nix
··· 52 52 # - Package: ../modules/${pname}/releases/package.nix 53 53 54 54 # FIXME: do this at the module system level 55 - propagatePlatforms = lib.mapAttrs (platform: subset: map (r: r // { inherit platform; }) subset); 55 + propagatePlatforms = lib.mapAttrs (redistArch: packages: map (p: { inherit redistArch; } // p) packages); 56 56 57 57 # All releases across all platforms 58 58 # See ../modules/${pname}/releases/releases.nix ··· 67 67 # isSupported :: Package -> Bool 68 68 isSupported = 69 69 package: 70 - # The `platform` attribute of the package is NVIDIA's name for a redistributable architecture. 71 - redistArch == package.platform 70 + redistArch == package.redistArch 72 71 && strings.versionAtLeast cudaVersion package.minCudaVersion 73 72 && strings.versionAtLeast package.maxCudaVersion cudaVersion; 74 73 ··· 77 76 # Value is `"unsupported"` if the platform is not supported. 78 77 redistArch = flags.getRedistArch hostPlatform.system; 79 78 80 - allReleases = lists.flatten (builtins.attrValues releaseSets); 79 + preferable = 80 + p1: p2: (isSupported p2 -> isSupported p1) && (strings.versionAtLeast p1.version p2.version); 81 81 82 82 # All the supported packages we can build for our platform. 83 83 # perSystemReleases :: List Package 84 - perSystemReleases = releaseSets.${redistArch} or [ ]; 84 + allReleases = lib.pipe releaseSets 85 + [ 86 + (builtins.attrValues) 87 + (lists.flatten) 88 + (builtins.groupBy (p: lib.versions.majorMinor p.version)) 89 + (builtins.mapAttrs (_: builtins.sort preferable)) 90 + (builtins.mapAttrs (_: lib.take 1)) 91 + (builtins.attrValues) 92 + (builtins.concatMap lib.trivial.id) 93 + ]; 85 94 86 - preferable = 87 - p1: p2: (isSupported p2 -> isSupported p1) && (strings.versionAtLeast p1.version p2.version); 88 95 newest = builtins.head (builtins.sort preferable allReleases); 89 96 90 97 # A function which takes the `final` overlay and the `package` being built and returns ··· 108 115 buildPackage = 109 116 package: 110 117 let 111 - shims = final.callPackage shimsFn {inherit package redistArch;}; 118 + shims = final.callPackage shimsFn {inherit package; inherit (package) redistArch; }; 112 119 name = computeName package; 113 120 drv = final.callPackage ./manifest.nix { 114 121 inherit pname; ··· 120 127 attrsets.nameValuePair name fixedDrv; 121 128 122 129 # versionedDerivations :: AttrSet Derivation 123 - versionedDerivations = builtins.listToAttrs (lists.map buildPackage perSystemReleases); 130 + versionedDerivations = builtins.listToAttrs (lists.map buildPackage allReleases); 124 131 125 132 defaultDerivation = { ${pname} = (buildPackage newest).value; }; 126 133 in