Skip to content

{coq,rocq}Packages.mk{Coq,Rocq}Derivation: move env variables into env for structuredAttrs - #492142

Merged
philiptaron merged 2 commits into
NixOS:masterfrom
SFrijters:coq-env
Jul 6, 2026
Merged

{coq,rocq}Packages.mk{Coq,Rocq}Derivation: move env variables into env for structuredAttrs#492142
philiptaron merged 2 commits into
NixOS:masterfrom
SFrijters:coq-env

Conversation

@SFrijters

@SFrijters SFrijters commented Feb 19, 2026

Copy link
Copy Markdown
Member

This probably needs some careful review because of the conditional variables.

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.

@SFrijters SFrijters changed the title coqPackages.mkCoqDerivation: move env variables into env for structur… coqPackages.mkCoqDerivation: move env variables into env for structuredAttrs Feb 19, 2026
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Feb 19, 2026
@SFrijters

Copy link
Copy Markdown
Member Author

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 492142
Commit: cb9287924a2ae9f6218bcdcddcaf8b661d97311c

@SFrijters
SFrijters marked this pull request as ready for review February 19, 2026 16:15
@nixpkgs-ci
nixpkgs-ci Bot requested a review from philiptaron February 19, 2026 16:27
@SFrijters
SFrijters requested review from qweered and vbgl March 18, 2026 19:52
// optionalAttrs (args ? useMelquiondRemake) {
inherit COQUSERCONTRIB;
}
// (args.env or { });

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should the args.env be at the end (making the variables above overridable), or at the top?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that's open to interpretation.

It depends on who should have the final say for COQBIN and COQUSERCONTRIB's values; args.COQBIN or setCOQBIN; args.COQUSERCONTRIB or useMelquiondRemake?

Or should we we warning/throwing when there is a conflict? We don't usually do that in nixpkgs, but it would be more explicit if you think this is prone to user error.

@SFrijters
SFrijters force-pushed the coq-env branch 2 times, most recently from 7d33727 to 0a7e0a1 Compare March 23, 2026 10:53
@SFrijters SFrijters changed the title coqPackages.mkCoqDerivation: move env variables into env for structuredAttrs {coq,rocq}Packages.mk{Coq,Rocq}Derivation: move env variables into env for structuredAttrs Mar 23, 2026
@SFrijters

Copy link
Copy Markdown
Member Author

Added the same change for rocqPackages, the question of ordering of env still applies.

@SFrijters
SFrijters requested a review from proux01 March 23, 2026 13:09
@SFrijters

Copy link
Copy Markdown
Member Author

@philiptaron Gentle poke for review?

@vbgl

vbgl commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Could you help debugging the following error:

error: The `env` attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping:
- COQBIN: in `env`: "/nix/store/…-coq-9.0.1/bin/"; in derivation arguments: ""

@SFrijters

SFrijters commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

What exactly are you doing to cause that error?

And does this new commit fix the issue? It may not be the right way to go, but at least it would help me understand what is happening. The rocq variant will need a similar fix, whatever it might end up being.

@vbgl

vbgl commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

I’m trying to use the coq-nix-toolbox to review this PR. Running genNixActions produces the reported error. Your latest commit did not help (no observable change).

@SFrijters

Copy link
Copy Markdown
Member Author

Almost certainly related to https://github.com/rocq-community/coq-nix-toolbox/blob/77b185941e037f5afd21dee4713b8d1be1d67aa9/default.nix#L106

My "fix" doesn't work because that repo seems to override whatever comes out of nixpkgs, not the other way around?

I'm not sure that line makes sense anyway? Using optionalString (condition) "" is just always "", no?
I assume it's meant to leave the variable alone if do-nothing? Then optionalAttrs would be better instead.

For forward compatibility it should blank either COQBIN or env.COQBIN, whichever exists.

@philiptaron philiptaron left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change LGTM from the Nixpkgs POV, I don't know the coq part of the ecosystem super-well though.

@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Apr 7, 2026
@SFrijters

Copy link
Copy Markdown
Member Author

@vbgl Do you have any plans for making the toolbox more compatible with env?

@vbgl

vbgl commented May 4, 2026

Copy link
Copy Markdown
Contributor

No plans on my side.

SFrijters added a commit to SFrijters/coq-nix-toolbox that referenced this pull request May 4, 2026
With structuredAttrs enabled, environment variables should live inside
the `env` attrset. In the case of this project, this affects COQBIN, as
per NixOS/nixpkgs#492142 , which moves it into env.

Setting `COQBIN = "";` in `default.nix` while `env.COQBIN` exists causes an evaluation error:

Error: The `env` attribute set cannot contain any attributes passed to derivation.

To fix this, remove the attr instead if it exists, in either place.
@SFrijters

Copy link
Copy Markdown
Member Author

Rebased on top of the pinned nixpkgs commit in coq-nix-toolbox for easier testing. @vbgl Could you take a look at rocq-community/coq-nix-toolbox#460 ?

@SFrijters

Copy link
Copy Markdown
Member Author

This is pretty much the only package set in nixpkgs that still has env variables outside of env so I would like to move ahead on this at some point - I have provided a likely solution for downstream and I don't like this issue lingering any more than necessary.

@proux01 Any thoughts on this and/or the PR I opened on the toolbox?

@MattSturgeon MattSturgeon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change LGTM from the Nixpkgs POV, I don't know the coq part of the ecosystem super-well though.

Same here

"dropDerivationAttrs"
"keepAttrs"
"enableParallelBuilding"
"env"

@MattSturgeon MattSturgeon May 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Off-topic:

It's unfortunate that // (removeAttrs args args-to-remove) is on the RHS of the update, so we need to explicitly "remove" args that'd shadow explicit overrides below. I assume there are other things that we'd want args to shadow the "default values" below?

These coq & rcoq builders would benefit from being refactored to use extendMkDerivation.

// optionalAttrs (args ? useMelquiondRemake) {
inherit COQUSERCONTRIB;
}
// (args.env or { });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that's open to interpretation.

It depends on who should have the final say for COQBIN and COQUSERCONTRIB's values; args.COQBIN or setCOQBIN; args.COQUSERCONTRIB or useMelquiondRemake?

Or should we we warning/throwing when there is a conflict? We don't usually do that in nixpkgs, but it would be more explicit if you think this is prone to user error.

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels May 25, 2026
@SFrijters

Copy link
Copy Markdown
Member Author

I'd like to move forward on this so it's off my PR list (and because we're getting really close to eliminating these free-ranging env variables overall), but I don't have much bandwidth at the moment to deal with any potential fallout if there are any unexpected issues, so I'd prefer if someone who actually uses Coq/Rocq could weigh in before I push a merge button.

@SFrijters

Copy link
Copy Markdown
Member Author

Rebased to resolved merge conflicts.

@SFrijters
SFrijters requested a review from Zimmi48 July 6, 2026 12:58
@philiptaron
philiptaron added this pull request to the merge queue Jul 6, 2026
Merged via the queue into NixOS:master with commit 9195f26 Jul 6, 2026
26 checks passed
vbgl pushed a commit to SFrijters/coq-nix-toolbox that referenced this pull request Jul 6, 2026
With structuredAttrs enabled, environment variables should live inside
the `env` attrset. In the case of this project, this affects COQBIN, as
per NixOS/nixpkgs#492142 , which moves it into env.

Setting `COQBIN = "";` in `default.nix` while `env.COQBIN` exists causes an evaluation error:

Error: The `env` attribute set cannot contain any attributes passed to derivation.

To fix this, remove the attr instead if it exists, in either place.

Update after NixOS/nixpkgs#492142
@SFrijters
SFrijters deleted the coq-env branch July 7, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants