_cuda.lib.allowUnfreeCudaPredicate: derive from _cuda.lib.licenses

Signed-off-by: Connor Baker <ConnorBaker01@gmail.com>
This commit is contained in:
Connor Baker
2025-09-24 00:22:44 +00:00
parent 4f81b9b642
commit ba2fa45461
3 changed files with 13 additions and 29 deletions

View File

@@ -26,23 +26,9 @@ All CUDA package sets include common CUDA packages like `libcublas`, `cudnn`, `t
CUDA support is not enabled by default in Nixpkgs. To enable CUDA support, make sure Nixpkgs is imported with a configuration similar to the following:
```nix
{ pkgs }:
{
allowUnfreePredicate =
let
ensureList = x: if builtins.isList x then x else [ x ];
in
package:
builtins.all (
license:
license.free
|| builtins.elem license.shortName [
"CUDA EULA"
"cuDNN EULA"
"cuSPARSELt EULA"
"cuTENSOR EULA"
"NVidia OptiX EULA"
]
) (ensureList package.meta.license);
allowUnfreePredicate = pkgs._cuda.lib.allowUnfreeCudaPredicate;
cudaCapabilities = [ <target-architectures> ];
cudaForwardCompat = true;
cudaSupport = true;

View File

@@ -1,4 +1,4 @@
{ lib }:
{ _cuda, lib }:
{
/**
Returns whether a capability should be built by default for a particular CUDA version.
@@ -114,16 +114,14 @@
```
*/
allowUnfreeCudaPredicate =
package:
lib.all (
license:
license.free
|| lib.elem license.shortName [
"CUDA EULA"
"cuDNN EULA"
"cuSPARSELt EULA"
"cuTENSOR EULA"
"NVidia OptiX EULA"
let
cudaLicenseNames = [
lib.licenses.nvidiaCuda.shortName
]
) (lib.toList package.meta.license);
++ lib.map (license: license.shortName) (lib.attrValues _cuda.lib.licenses);
in
package:
lib.all (license: license.free || lib.elem license.shortName cudaLicenseNames) (
lib.toList package.meta.license
);
}

View File

@@ -11,7 +11,7 @@
;
# See ./cuda.nix for documentation.
inherit (import ./cuda.nix { inherit lib; })
inherit (import ./cuda.nix { inherit _cuda lib; })
_cudaCapabilityIsDefault
_cudaCapabilityIsSupported
_mkCudaVariant