-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
tree-wide: cudaPackages attributes should not cause default eval to fail #274319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
501a1af
9bebd9e
5e472d9
5c260fa
39cab2b
b2f97e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,9 @@ let | |
| # Get the redist architectures for which package provides distributables. | ||
| # These are used by meta.platforms. | ||
| supportedRedistArchs = builtins.attrNames featureRelease; | ||
| # redistArch :: String | ||
| # The redistArch is the name of the architecture for which the redistributable is built. | ||
| # It is `"unsupported"` if the redistributable is not supported on the target platform. | ||
| redistArch = flags.getRedistArch hostPlatform.system; | ||
| in | ||
| backendStdenv.mkDerivation ( | ||
|
|
@@ -86,8 +89,18 @@ backendStdenv.mkDerivation ( | |
| "sample" | ||
| "python" | ||
| ]; | ||
| # Filter out outputs that don't exist in the redistributable. | ||
| # NOTE: In the case the redistributable isn't supported on the target platform, | ||
| # we will have `outputs = [ "out" ] ++ possibleOutputs`. This is of note because platforms which | ||
| # aren't supported would otherwise have evaluation errors when trying to access outputs other than `out`. | ||
| # The alternative would be to have `outputs = [ "out" ]` when`redistArch = "unsupported"`, but that would | ||
| # require adding guards throughout the entirety of the CUDA package set to ensure `cudaSupport` is true -- | ||
| # recall that OfBorg will evaluate packages marked as broken and that `cudaPackages` will be evaluated with | ||
| # `cudaSupport = false`! | ||
| additionalOutputs = | ||
| if redistArch == "unsupported" then possibleOutputs else builtins.filter hasOutput possibleOutputs; | ||
| if redistArch == "unsupported" | ||
| then possibleOutputs | ||
| else builtins.filter hasOutput possibleOutputs; | ||
| # The out output is special -- it's the default output and we always include it. | ||
| outputs = [ "out" ] ++ additionalOutputs; | ||
| in | ||
|
|
@@ -111,21 +124,32 @@ backendStdenv.mkDerivation ( | |
| python = ["**/*.whl"]; | ||
| }; | ||
|
|
||
| # Useful for introspecting why something went wrong. | ||
| # Maps descriptions of why the derivation would be marked broken to | ||
| # booleans indicating whether that description is true. | ||
| brokenConditions = {}; | ||
| # Useful for introspecting why something went wrong. Maps descriptions of why the derivation would be marked as | ||
| # broken on have badPlatforms include the current platform. | ||
|
|
||
| src = fetchurl { | ||
| url = | ||
| if (builtins.hasAttr redistArch redistribRelease) then | ||
| "https://developer.download.nvidia.com/compute/${redistName}/redist/${ | ||
| redistribRelease.${redistArch}.relative_path | ||
| }" | ||
| else | ||
| "cannot-construct-an-url-for-the-${redistArch}-platform"; | ||
| sha256 = redistribRelease.${redistArch}.sha256 or lib.fakeHash; | ||
| }; | ||
| # brokenConditions :: AttrSet Bool | ||
| # Sets `meta.broken = true` if any of the conditions are true. | ||
| # Example: Broken on a specific version of CUDA or when a dependency has a specific version. | ||
| brokenConditions = { }; | ||
|
|
||
| # badPlatformsConditions :: AttrSet Bool | ||
| # Sets `meta.badPlatforms = meta.platforms` if any of the conditions are true. | ||
| # Example: Broken on a specific architecture when some condition is met (like targeting Jetson). | ||
| badPlatformsConditions = { }; | ||
|
|
||
| # src :: Optional Derivation | ||
| src = trivial.pipe redistArch [ | ||
| # If redistArch doesn't exist in redistribRelease, return null. | ||
| (redistArch: redistribRelease.${redistArch} or null) | ||
| # If the release is non-null, fetch the source; otherwise, return null. | ||
| (trivial.mapNullable ( | ||
| { relative_path, sha256, ... }: | ||
| fetchurl { | ||
| url = "https://developer.download.nvidia.com/compute/${redistName}/redist/${relative_path}"; | ||
| inherit sha256; | ||
| } | ||
| )) | ||
| ]; | ||
|
|
||
| postPatch = '' | ||
| if [[ -d pkg-config ]] ; then | ||
|
|
@@ -284,17 +308,18 @@ backendStdenv.mkDerivation ( | |
| meta = { | ||
| description = "${redistribRelease.name}. By downloading and using the packages you accept the terms and conditions of the ${finalAttrs.meta.license.shortName}"; | ||
| sourceProvenance = [sourceTypes.binaryNativeCode]; | ||
| platforms = | ||
| lists.concatMap | ||
| ( | ||
| redistArch: | ||
| let | ||
| nixSystem = flags.getNixSystem redistArch; | ||
| in | ||
| lists.optionals (!(strings.hasPrefix "unsupported-" nixSystem)) [ nixSystem ] | ||
| ) | ||
| supportedRedistArchs; | ||
| broken = lists.any trivial.id (attrsets.attrValues finalAttrs.brokenConditions); | ||
| platforms = trivial.pipe supportedRedistArchs [ | ||
| # Map each redist arch to the equivalent nix system or null if there is no equivalent. | ||
| (builtins.map flags.getNixSystem) | ||
| # Filter out unsupported systems | ||
| (builtins.filter (nixSystem: !(strings.hasPrefix "unsupported-" nixSystem))) | ||
| ]; | ||
| badPlatforms = | ||
| let | ||
| isBadPlatform = lists.any trivial.id (attrsets.attrValues finalAttrs.badPlatformsConditions); | ||
| in | ||
| lists.optionals isBadPlatform finalAttrs.meta.platforms; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Is this less or more confusing than adding just the current platform?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's fine, personally.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup probably a good thing we get the same meta regardless of where we evaluate |
||
| license = licenses.unfree; | ||
| maintainers = teams.cuda.members; | ||
| # Force the use of the default, fat output by default (even though `dev` exists, which | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, I introduced the stringly string because I was in a rush. We should probably return some sort of
Result/{ value, error }(e.g. in the format oftryEval)I'll add a ticket to the project board for that