Skip to content

_cuda.lib.allowUnfreeCudaPredicate: handle compound licenses - #550208

Merged
SomeoneSerge merged 1 commit into
NixOS:masterfrom
SuperSandro2000:cuda-license
Sep 4, 2026
Merged

SomeoneSerge merged 1 commit into
NixOS:masterfrom
SuperSandro2000:cuda-license

Conversation

@SuperSandro2000

@SuperSandro2000 SuperSandro2000 commented Aug 7, 2026 •

Copy link
Copy Markdown
Member

Some package I use has a compound license (no idea which)

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'free' missing
       at «git+https://github.com/SuperSandro2000/nixpkgs.git?ref=nixos-unstable&rev=1e70c06a4d3e661657a25ec2baf5919c24f3133e&shallow=1»/pkgs/development/cuda-modules/_cuda/lib/cuda.nix:124:23:
          123|     package:
          124|     lib.all (license: license.free || lib.elem (license.shortName or null) cudaLicenseNames) (
             |                       ^
          125|       lib.toList package.meta.license

I could only find out that it is this license:

nix-repl> :p license
{
  licenseType = "compound";
  licenses = [
    {
      deprecated = false;
      free = true;
      fullName = "GNU General Public License v2.0 or later";
      licenseType = "simple";
      redistributable = true;
      shortName = "gpl2Plus";
      spdxId = "GPL-2.0-or-later";
      url = "https://spdx.org/licenses/GPL-2.0-or-later.html";
    }
    {
      deprecated = false;
      free = true;
      fullName = "Apache License 2.0";
      licenseType = "simple";
      redistributable = true;
      shortName = "asl20";
      spdxId = "Apache-2.0";
      url = "https://spdx.org/licenses/Apache-2.0.html";
    }
  ];
  operator = "AND";
}

Things done

@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team August 7, 2026 15:16
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 6.topic: cuda Parallel computing platform and API labels Aug 7, 2026
@ConnorBaker

Copy link
Copy Markdown
Contributor

Okay, what fresh hell is this where are licenses formally defined because that looks suspiciously like another EDSL? I know that there’s a check-meta — does it handle licenses? What is the canonical format? I want to avoid growing a predicate into a SAT solver and am much more concerned now than I was with my previous understanding of how the licenses are laid out.

@djacu

djacu commented Aug 7, 2026

Copy link
Copy Markdown
Member

operator = "AND";
🫪

@SomeoneSerge

SomeoneSerge commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Okay, what fresh hell is this

I recall https://discourse.nixos.org/t/compound-licenses/78532/ this popping up in my email and me thinking exactly these words, not sure we're prepared to work with more detailed/complex data

@SuperSandro2000

Copy link
Copy Markdown
Member Author

@ConnorBaker I have no idea. My stuff fell apart and I saw this as the quickest, low dirty way to fix stuff.

@SuperSandro2000

Copy link
Copy Markdown
Member Author

I re-used a helper from lib.licenses to avoid adding to much duplicated logic.

@SuperSandro2000

Copy link
Copy Markdown
Member Author

This worked for one of my machines but fell apart for another one ....

@SuperSandro2000
SuperSandro2000 force-pushed the cuda-license branch 3 times, most recently from 56aabfb to 664ab37 Compare August 9, 2026 16:19
@jopejoe1

jopejoe1 commented Aug 13, 2026 •

Copy link
Copy Markdown
Member
Side tangent: maybe a bit ranty/frustrated. TBH: We have `config.allowlistedLicenses` to allow specific licenses, without allowing all other unfree licenses, so why does CUDA need their own allowed license implementation using `config.allowPredicate` instead of just providing a simple list for `config.allowlistedLicenses`?

@SuperSandro2000

Copy link
Copy Markdown
Member Author

Good question, that would make things probably a lot easier.

@SuperSandro2000

Copy link
Copy Markdown
Member Author

@NixOS/cuda-maintainers Can we move forward with this? It is becoming a problem for me in feature branches.

@ConnorBaker ConnorBaker self-assigned this Aug 16, 2026
@SomeoneSerge

SomeoneSerge commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

TBH: We have config.allowlistedLicenses to allow specific licenses, without allowing all other unfree licenses, so why does CUDA need their own allowed license implementation using config.allowPredicate instead of just providing a simple list for

allowListedLicenses compares attrsets, not shortNames; CUDAToolkit consists of 10s of components each of which come with a copy of the same license but e.g. a different URL, so these licenses are not going into lib.licenses.

The PR introducing "compound" licenses really should not have changed the signature of allowUnfreePredicate.

We're syncing on whether we're ok adding the hack nonetheless...

@jopejoe1

jopejoe1 commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

TBH: We have config.allowlistedLicenses to allow specific licenses, without allowing all other unfree licenses, so why does CUDA need their own allowed license implementation using config.allowPredicate instead of just providing a simple list for

allowListedLicenses compares attrsets, not shortNames; CUDAToolkit consists of 10s of components each of which come with a copy of the same license but e.g. a different URL, so these licenses are not going into lib.licenses.

They don't need to be listed in lib.licenses to be included in config.allowlistedLicenses settings config.allowlistedLicenses to this would have the same result as your current allowUnfreePredicate.

config.allowlistedLicenses = [ 
  lib.licenses.nvidiaCuda
  lib.licenses.nvidiaCudaRedist
]
++ lib.attrValues _cuda.lib.licenses;

The PR introducing "compound" licenses really should not have changed the signature of allowUnfreePredicate.

The signature of licenses is just any attrs or string or list of those (and you could find very wild stuff in the license field before I clean it up a bit).

What is the canonical format?

There is no other than an implied looks similar to the ones in lib.licenses, im working on creating one, but it does not exist yet.

I know that there’s a check-meta — does it handle licenses?

Yes, it handles them via allowlistedLicenses and blocklistedLicenses and also does a type check.

@SomeoneSerge

SomeoneSerge commented Aug 19, 2026 via email

Copy link
Copy Markdown
Contributor

@SomeoneSerge

SomeoneSerge commented Aug 19, 2026 via email

Copy link
Copy Markdown
Contributor

@jopejoe1

jopejoe1 commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

I'm afraid not, _cuda.lib.licenses does not contain all instantiations of cuda-related licenses (also this highlights another lossy rebase, probably coming from the cuda13 PR, which dropped the //{ url = ... } part for a TODO comment xDD)

Probably missed those as I only checked the packages that are included in the search index.
Edit: could not find any in tree that were not in _cuda.lib.licenses or lib.licenses please do point me to them if you find any.

It's not, hasn't been for a long time! We've had an mkLicense primitive which enforced that a bunch of attributes must exist, we've had maybe Emily or Philip patch up the ad hoc licenses in cudaPackages to satisfy the same format, so we've definitely had a notion of a "License" type/interface, however loose, and the signature indeed was (License | [License]) -> Bool

I wish that were the case, but sadly it still is not the reality, we are still working on actually implementing that fully.

@ConnorBaker

Copy link
Copy Markdown
Contributor

They don't need to be listed in lib.licenses to be included in config.allowlistedLicenses settings config.allowlistedLicenses to this would have the same result as your current allowUnfreePredicate.

config.allowlistedLicenses = [ 
  lib.licenses.nvidiaCuda
  lib.licenses.nvidiaCudaRedist
]
++ lib.attrValues _cuda.lib.licenses;

Except yes they did, otherwise you run into infinite recursion because the package set cannot depend on its values in such a fashion:

$ git checkout f6a38f9a4e93843f83942b735f316ff85d495600
$ nix eval -f . --arg config '{pkgs, ...}: { allowlistedLicenses = [pkgs.lib.licenses.nvidiaCuda pkgs.lib.licenses.nvidiaCudaRedist] ++ pkgs.lib.attrValues pkgs._cuda.lib.licenses; }' cudaPackages.cudnn
error:
       … while evaluating a branch condition
         at /home/connorbaker/nixpkgs/pkgs/stdenv/booter.nix:107:9:
          106|       thisStage =
          107|         if args.__raw or false then
             |         ^
          108|           args'

       … in the right operand of the update (//) operator
         at /home/connorbaker/nixpkgs/pkgs/stdenv/booter.nix:90:48:
           89|     # for the final stage.
           90|     { allowCustomOverrides = index == 1; } // (stageFun prevStage)
             |                                                ^
           91|   ) (lib.lists.reverseList stageFuns);

       … while evaluating definitions from `nixpkgs.config':

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: infinite recursion encountered
       at «string»:1:107:
            1| {pkgs, ...}: { allowlistedLicenses = [pkgs.lib.licenses.nvidiaCuda pkgs.lib.licenses.nvidiaCudaRedist] ++ pkgs.lib.attrValues pkgs._cuda.lib.licenses; }
             |

It works now, but that is the result of other changes to config.nix:

$ git checkout master
Updating files: 100% (45890/45890), done.
Previous HEAD position was f6a38f9a4e93 Revert "config: add and document {allow,block}listedLicenses"
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
$ nix eval -f . --arg config '{pkgs, ...}: { allowlistedLicenses = [pkgs.lib.licenses.nvidiaCuda pkgs.lib.licenses.nvidiaCudaRedist] ++ pkgs.lib.attrValues pkgs._cuda.lib.licenses; }' cudaPackages.cudnn
«derivation /nix/store/xahxp5z24n3bhh0ab51aiz3h2slqa24v-cuda12.9-cudnn-9.22.0.52.drv»

Using allowUnfreePredicate allowed me to sidestep the problem for whatever reason (relating to the fixed point).

Also different are the semantics: join (allow list) vs. meet (our predicate). As well as the method of comparison.

@SuperSandro2000

Copy link
Copy Markdown
Member Author

So what are we doing now? 😅

@SomeoneSerge

Copy link
Copy Markdown
Contributor

@SuperSandro2000 hi, sorry about latency, them are crazy times... we had concluded we should've probably merged your patch right away and then pushed for reverting and reworking compound licenses after the fact, but then everyone got distracted by a 1000 other urgent things. Apologies.

Pre-merge check:

Details $ nix eval -I nixpkgs=flake:github:SuperSandro2000/nixpkgs/cuda-license -f "" --arg config '{ pkgs, ... }: { allowUnfreePredicate = pkgs._cuda.lib.allowUnfreeCudaPredicate; }' cudaPackages.cuda_nvcc «derivation /nix/store/nmwccpzdf933kc8pwyqq8g8x5czglwcx-cuda12.9-cuda_nvcc-12.9.86.drv»

PS To anyone else reading: _cuda attribute is private, every name (including the predicate) subject to change, semantics subject to change, the mkCudaPackages subject to change/disappearance, etc, etc, etc

@SomeoneSerge
SomeoneSerge added this pull request to the merge queue Sep 4, 2026
Merged via the queue into NixOS:master with commit dfac7c2 Sep 4, 2026
25 of 27 checks passed
@github-project-automation github-project-automation Bot moved this from New to ✅ Done in CUDA Team Sep 4, 2026
@SomeoneSerge SomeoneSerge added the backport release-26.05 Backport PR automatically label Sep 4, 2026
@nixpkgs-ci

nixpkgs-ci Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-26.05:

@github-actions github-actions Bot added the 8.has: port to stable This PR already has a backport to the stable release. label Sep 4, 2026
@SuperSandro2000
SuperSandro2000 deleted the cuda-license branch September 5, 2026 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: cuda Parallel computing platform and API 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. backport release-26.05 Backport PR automatically

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

5 participants