Skip to content

mkDerivation: make allowedReference/allowedRequisites nullable when __structuredAttrs is true#462141

Merged
philiptaron merged 1 commit intoNixOS:masterfrom
ShamrockLee:stdenv-makeOutputChecks-allowedR-null
Feb 13, 2026
Merged

mkDerivation: make allowedReference/allowedRequisites nullable when __structuredAttrs is true#462141
philiptaron merged 1 commit intoNixOS:masterfrom
ShamrockLee:stdenv-makeOutputChecks-allowedR-null

Conversation

@ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Nov 16, 2025

stdenv.mkDerivation { allowedRequisites = null; } should work whether __structuredAttrs is false or true.

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.

@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: stdenv Standard environment labels Nov 16, 2025
@ShamrockLee ShamrockLee force-pushed the stdenv-makeOutputChecks-allowedR-null branch from 8164203 to b803d30 Compare November 16, 2025 05:46
@ShamrockLee ShamrockLee marked this pull request as ready for review November 16, 2025 05:54
@ShamrockLee
Copy link
Contributor Author

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 462141
Commit: b803d3076034aef35a40b3ba2bc0f2458e639840 (subsequent changes)
Merge: d380d3cad68a2e82687871ca55bd475076d52b14

Logs: https://github.com/ShamrockLee/nixpkgs-review-gha/actions/runs/19401209750


x86_64-linux

✅ 1 package built:
  • tests.overriding

aarch64-linux

✅ 1 package built:
  • tests.overriding

x86_64-darwin (sandbox = true)

✅ 1 package built:
  • tests.overriding

aarch64-darwin (sandbox = true)

✅ 1 package built:
  • tests.overriding

@wolfgangwalther
Copy link
Contributor

Why would I set these to null instead of [] to disable?

@ShamrockLee
Copy link
Contributor Author

Why would I set these to null instead of [] to disable?

These two variables are the whitelists. allowedReferences = [ ]; forbids this derivation from depending on any other packages.

Comment on lines 732 to 735
raw = zipAttrsWith (_: builtins.concatLists) [
(makeOutputChecks attrs)
attrsOutputChecksFiltered
(makeOutputChecks attrs.outputChecks.${name} or { })
];
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to imagine when setting allowedRe... = null is useful - and I think it only makes sense when overriding attrs, right?

But consider this:

mkDerivation {
  __structuredAttrs = true;
  outputChecks.allowedRequisites = [ foo ];
}

When overriding this with allowedRequisites = null;, it will not have the intended effect - foo will still be in there.

When overriding attrs of a structuredAttrs-enabled derivation, then you just need to override outputChecks.... and not the non-structured-attrs variant.

We only have this compatibility hack to be able to create derivations that don't specify __structuredAttrs at all, i.e. rely on the default, and will then still work when flipping the default later.

I think we don't need to support overrideAttrs for this thing - it's discouraged from using inside Nixpkgs anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there is a package with { allowedRequisites = [ ... ]; }, and I want to override it so to be { __structuredAttrs = true; }; it would then be helpful to cancel the top-level allowedRequisites with null.

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 24, 2026
@nixpkgs-ci nixpkgs-ci bot requested a review from a team February 10, 2026 02:05
@philiptaron philiptaron force-pushed the stdenv-makeOutputChecks-allowedR-null branch from b803d30 to eddb12a Compare February 13, 2026 01:05
@nixpkgs-ci nixpkgs-ci bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Feb 13, 2026
@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Feb 13, 2026
@philiptaron philiptaron added this pull request to the merge queue Feb 13, 2026
Merged via the queue into NixOS:master with commit 4470071 Feb 13, 2026
30 of 32 checks passed
@github-project-automation github-project-automation bot moved this to Done in Stdenv Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: stdenv Standard environment 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. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants