Skip to content

treewide: fix rec-set-dynamic-attrs - #479126

Merged
piegamesde merged 1 commit into
NixOS:masterfrom
just1602:push-psvrsutznylr
Jan 14, 2026
Merged

piegamesde merged 1 commit into
NixOS:masterfrom
just1602:push-psvrsutznylr

Conversation

@just1602

Copy link
Copy Markdown
Contributor

Lix will soon warn, and in the future, error on rec-set-dynamic-attrs. This commit fix where attrs are dynamically set in a recursive function currently present in nixpkgs.

@piegamesde

  • 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: 0 This PR does not cause any packages to rebuild on Darwin. 6.topic: dotnet Language: .NET labels Jan 11, 2026
@corngood

Copy link
Copy Markdown
Contributor

Lix will soon warn, and in the future, error on rec-set-dynamic-attrs

Can you link to some documentation about this?

@piegamesde

Copy link
Copy Markdown
Member

https://gerrit.lix.systems/c/lix/+/4652/11 is the CL for this which contains documentation for the feature flag and release notes, but there will be announcements on the Lix blog as well in time

@corngood

Copy link
Copy Markdown
Contributor

I don't necessarily have a problem with the changes here, but has there been some discussion somewhere leading to a consensus that this should be enforced? The linked review seems to be WIP and has no discussion.

I'd really like to see an example of the kind of counter-intuitive behaviour this can help avoid.

@piegamesde

Copy link
Copy Markdown
Member

The motivating incidents are NixOS/nix#14642 (comment) and NixOS/nix#11268 (comment)

The code that handles these syntax combinations is fairly complex and would probably need to be refactored in order to support this properly.
Most of the complexity comes from the combinations with dynamic attributes (${name} = v;)

Unlike other deprecations currently being worked on, the subtle language semantics here are not as big of an issue for typical programmers, apart from them maybe running into an unintuitive "variable not defined" error. But as these issues show, the implementation is complex, heavy on maintenance and brittle, elevating a minor grammar regression into a major soundness issue.

@piegamesde piegamesde left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me so far

@corngood-bot

Copy link
Copy Markdown

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 479126
Commit: ccd040d0d6465866ccfee06c7639e5d8e29a94fa (subsequent changes)
Merge: c4480681e6cc797744d0b4a0f1d6575d7e713d86

Logs: https://github.com/corngood/nixpkgs-review-gha/actions/runs/20931987914


x86_64-linux

⏩ 2 packages marked as broken and skipped:
  • sublime4
  • sublime4-dev
✅ 2 packages built:
  • sublime-merge
  • sublime-merge-dev

aarch64-linux

⏩ 2 packages marked as broken and skipped:
  • sublime4
  • sublime4-dev
✅ 2 packages built:
  • sublime-merge
  • sublime-merge-dev

x86_64-darwin

✅ No rebuilds


aarch64-darwin

✅ No rebuilds

Comment on lines -101 to -107
passthru = rec {
new = fstarNewZ3;
"z3_${lib.replaceStrings [ "." ] [ "_" ] fstarNewZ3.version}" = new;

old = fstarOldZ3;
"z3_${lib.replaceStrings [ "." ] [ "_" ] fstarOldZ3.version}" = old;
};

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.

Could just remove the rec and use the same value for both attributes.

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.

Yeah. I'd prefer we keep the passthru on this, since it is useful to expose these attributes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, we were told they were not used, but yeah we can keep them.

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.

No worries. No, not used inside nixpkgs at least :)

@corngood

Copy link
Copy Markdown
Contributor

The motivating incidents are NixOS/nix#14642 (comment) and NixOS/nix#11268 (comment)

Thanks! That's very interesting.

The dotnet changes all look good to me.

@corngood

corngood commented Jan 13, 2026 •

Copy link
Copy Markdown
Contributor

Is there any sort of plan to check/enforce this in nixpkgs? I just came across a case where I wanted to locally change an attribute to dynamic, and it occurred to me that it would be frustrating if I had to refactor a rec.

This might not be the place to discuss it, but none of the linked issues seem right.

@piegamesde

Copy link
Copy Markdown
Member

We already have parser tests https://github.com/NixOS/nixpkgs/blob/master/ci/parse.nix, so this will automatically apply when the changes are released in Lix. We may want to modify the check so that it also triggers on deprecation warnings and not only parse errors, but that should be fairly straightforward to do

@corngood

Copy link
Copy Markdown
Contributor

Are there any sort of standards for nixpkgs compatibility with Lix? I know there's usually an older version of Nix that it's meant to evaluate on.

Assuming we do want to enforce this deprecation, how would we check for regressions?

@wolfgangwalther

Copy link
Copy Markdown
Contributor

Assuming we do want to enforce this deprecation, how would we check for regressions?

I must admit I had to check the timestamps of your message and of @piegamesde message right above. But it seems you were already aware of that message. That makes me confused. The message said: (I don't even know what to quote, it's the whole message talking exactly about this).

What exactly are you asking?

@corngood

Copy link
Copy Markdown
Contributor

What exactly are you asking?

Sorry, I thought that was only tested on nix. I kept digging and found:

  parse = pkgs.lib.recurseIntoAttrs {
    latest = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.latest; };
    lix = pkgs.callPackage ./parse.nix { nix = pkgs.lix; };
    nix_2_28 = pkgs.callPackage ./parse.nix { nix = pkgs.nixVersions.nix_2_28; };
  };

That's what I was missing. I was just trying to find the place where we enforce that nixpkgs parses on Lix.

Lix will soon warn, and in the future, error on `rec-set-dynamic-attrs`.
This commit fix where attrs are dynamically set in a recursive function
currently present in nixpkgs.
@piegamesde
piegamesde added this pull request to the merge queue Jan 14, 2026
Merged via the queue into NixOS:master with commit 2d6dc3d Jan 14, 2026
2 of 4 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Successfully created backport PR for release-25.11:

@github-actions github-actions Bot added the 8.has: port to stable This PR already has a backport to the stable release. label Jan 14, 2026
@just1602
just1602 deleted the push-psvrsutznylr branch January 14, 2026 18:14
just1602 added a commit to just1602/nixpkgs that referenced this pull request Jan 16, 2026
This is a backport of `NixOS#479126`.

> Lix will soon warn, and in the future, error on `rec-set-dynamic-attrs`.
> This commit fix where attrs are dynamically set in a recursive function
> currently present in nixpkgs.
just1602 added a commit to just1602/nixpkgs that referenced this pull request Jan 16, 2026
This is a backport of `NixOS#479126`.

> Lix will soon warn, and in the future, error on `rec-set-dynamic-attrs`.
> This commit fix where attrs are dynamically set in a recursive function
> currently present in nixpkgs.
just1602 added a commit to just1602/nixpkgs that referenced this pull request Jan 16, 2026
This is a backport of `NixOS#479126`.

Not-cherry-picked-because: there was more packages to fix then in 25.11 and master.

> Lix will soon warn, and in the future, error on `rec-set-dynamic-attrs`.
> This commit fix where attrs are dynamically set in a recursive function
> currently present in nixpkgs.
just1602 added a commit to just1602/nixpkgs that referenced this pull request Jan 16, 2026
This is a backport of `NixOS#479126`.

Not-cherry-picked-because: there was more packages to fix then in 25.11 and master.

> Lix will soon warn, and in the future, error on `rec-set-dynamic-attrs`.
> This commit fix where attrs are dynamically set in a recursive function
> currently present in nixpkgs.
just1602 added a commit to just1602/nixpkgs that referenced this pull request Jan 16, 2026
This is a backport of `NixOS#479126`.

Not-cherry-picked-because: there was more packages to fix then in 25.11 and master.

> Lix will soon warn, and in the future, error on `rec-set-dynamic-attrs`.
> This commit fix where attrs are dynamically set in a recursive function
> currently present in nixpkgs.
Ma27 added a commit to Ma27/nixpkgs that referenced this pull request Feb 18, 2026
Ma27 added a commit to Ma27/nixpkgs that referenced this pull request Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: dotnet Language: .NET 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants