about summary refs log tree commit diff
path: root/pkgs/development/cuda-modules/generic-builders
diff options
context:
space:
mode:
authorConnor Baker <connor.baker@tweag.io>2024-01-09 15:33:13 +0000
committerConnor Baker <connor.baker@tweag.io>2024-01-10 01:15:01 +0000
commit5c260fa5321120f660578674c6d41f54b4290f21 (patch)
treee01b15d79b6c6dbf047d363ea5dc41d4958ca74a /pkgs/development/cuda-modules/generic-builders
parent5e472d946836bb1be3e2ba30e01d746d5b597876 (diff)
cudaPackages: set badPlatforms when cudaSupport is false
Diffstat (limited to 'pkgs/development/cuda-modules/generic-builders')
-rw-r--r--pkgs/development/cuda-modules/generic-builders/manifest.nix26
1 files changed, 20 insertions, 6 deletions
diff --git a/pkgs/development/cuda-modules/generic-builders/manifest.nix b/pkgs/development/cuda-modules/generic-builders/manifest.nix
index f77a1a6385a92..dcc7c91d1e28d 100644
--- a/pkgs/development/cuda-modules/generic-builders/manifest.nix
+++ b/pkgs/development/cuda-modules/generic-builders/manifest.nix
@@ -4,6 +4,7 @@
   autoAddCudaCompatRunpathHook,
   autoPatchelfHook,
   backendStdenv,
+  config,
   fetchurl,
   lib,
   lndir,
@@ -124,14 +125,22 @@ 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.
-    # NOTE: This should not include reasons relating to the architecture, as those are handled by
-    # the `badPlatforms` attribute.
+    # 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.
+
     # 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 or when cudaSupport is false (building with CUDA essentially targets)
+    # a platform which NixOS doesn't have a notion of, otherwise we would specify the platform directly.
+    badPlatformsConditions = {
+      "CUDA support is disabled" = !config.cudaSupport;
+    };
+
     # src :: Optional Derivation
     src = trivial.pipe redistArch [
       # If redistArch doesn't exist in redistribRelease, return null.
@@ -303,13 +312,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];
+      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)))
       ];
-      broken = lists.any trivial.id (attrsets.attrValues finalAttrs.brokenConditions);
+      badPlatforms =
+        let
+          isBadPlatform = lists.any trivial.id (attrsets.attrValues finalAttrs.badPlatformsConditions);
+        in
+        lists.optionals isBadPlatform finalAttrs.meta.platforms;
       license = licenses.unfree;
       maintainers = teams.cuda.members;
       # Force the use of the default, fat output by default (even though `dev` exists, which