Skip to content

config.{allow,block}listedLicenses: fixups#457038

Closed
ConnorBaker wants to merge 3 commits intoNixOS:masterfrom
ConnorBaker:fix/config-licenses-infinite-recursion
Closed

config.{allow,block}listedLicenses: fixups#457038
ConnorBaker wants to merge 3 commits intoNixOS:masterfrom
ConnorBaker:fix/config-licenses-infinite-recursion

Conversation

@ConnorBaker
Copy link
Contributor

@ConnorBaker ConnorBaker commented Oct 30, 2025

As title.

Hot-fix for #456994.

Ideally this wouldn't cause infinite recursion, but I don't have the bandwidth to investigate that right now. Using types.raw is fine (that's the default for values which don't have an option here) and lets us keep the module documentation.

Additionally, introduces module options for blacklistedLicenses and whitelistedLicenses through mkRenamedOptionModuleWith, continuing the work started in #114127 by creating warnings when used in future releases. This also reverts the unintentional breaking change introduced by f5deefd which removed usage of blacklistedLicenses and whitelistedLicenses from check-meta.nix.

EDIT: mkRenamedOptionModuleWith is incompatible with types.raw when the aliased module supplies a default because types.raw prevents merging: #457038 (comment).

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@me-and
Copy link
Member

me-and commented Oct 30, 2025

This fixes my problem in #456994. Thank you!

@me-and
Copy link
Member

me-and commented Oct 30, 2025

Having done a bit of digging into why this is causing infinite recursion (I got nerd-sniped by the "for reasons which aren't immediately clear" comment...) I've identified the problem and proposed a somewhat scarier but possibly more "correct" fix at #457120.

Copy link
Member

@emilazy emilazy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a reasonable quick fix if the original commit is not reverted.

Comment on lines +238 to +240
# NOTE: The type should be `types.listOf (types.attrsOf types.anything)` -- however, this causes infinite
# recursion when `config` is a function for reasons which aren't immediately clear.
# For now, we use types.raw, the same type used by `freeformType`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems clear to me: the available attributes of pkgs depend on at least config.allowAliases, so pkgs.lib cannot be resolved without considering at least some of config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would make sense for why config.allowAliases cannot depend on pkgs, but that doesn't make sense for licenses (the value of which should not add or remove packages, but determine whether they evaluate).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the wording to be less ambiguous -- thank you @me-and for diving into the call stack in #457120 (comment)!

…finite recursion

Signed-off-by: Connor Baker <ConnorBaker01@gmail.com>
…leWith

Signed-off-by: Connor Baker <ConnorBaker01@gmail.com>
Signed-off-by: Connor Baker <ConnorBaker01@gmail.com>
@ConnorBaker ConnorBaker force-pushed the fix/config-licenses-infinite-recursion branch from 6b94fcd to d479586 Compare October 31, 2025 19:09
@ConnorBaker ConnorBaker requested a review from emilazy October 31, 2025 19:11
@ConnorBaker ConnorBaker changed the title config.{allow,block}listedLicenses: switch to types.raw to prevent infinite recursion config.{allow,block}listedLicenses: fixups Oct 31, 2025
@ConnorBaker
Copy link
Contributor Author

Well, mkRenamedOptionModuleWith won't work here because we can only use types.raw, which prevents merging, so both options (allowlistedLicenses and whitelistedLicenses or blocklistedLicenses and blacklistedLicenses) providing the default of [ ] causes and evaluation error:

       error: The option `allowlistedLicenses' is defined multiple times while it's expected to be unique.

       Definition values:
       - In `/nix/store/ys7j7kdp249w2mcbxcppnmna01vq7693-source/pkgs/top-level/config.nix': [ ]
       - In `nixpkgs.config': [ ]

I'm closing this PR and introducing another which reverts this change entirely.

ConnorBaker added a commit to ConnorBaker/nixpkgs that referenced this pull request Oct 31, 2025
This reverts commit f5deefd.

See:

- NixOS#437723 (introduced commit)
- NixOS#456994 (reported breakage)
- NixOS#457038 (attempted fix, closed in favor of this revert)
- NixOS#457120 (fix which would require more breaking changes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants