Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib.customisation.makeScope: Make overrideScope consistent with makeScopeWithSplicing #248988

Merged
merged 2 commits into from
Aug 14, 2023

Conversation

Artturin
Copy link
Member

@Artturin Artturin commented Aug 13, 2023

Right now converting makeScope to makeScopeWithSplicing is not transparent to users and requires adding a warning for overrideScope' in the set itself.

Warning and overrideScope' were added in 2018 b9dce11 and there should be no users left after 5 years.

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@Artturin Artturin requested review from infinisil and a user August 13, 2023 22:48
@github-actions github-actions bot added the 6.topic: lib The Nixpkgs function library label Aug 13, 2023
@Artturin Artturin changed the title lib.customisation.makeScope: Make overrideScope consistent with `ma… lib.customisation.makeScope: Make overrideScope consistent with makeScopeWithSplicing Aug 13, 2023
Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

Oof, the fact that overrideScope' didn't even exist on makeScopeWithSplicing is pretty bad, because depending on the set, only one of overrideScope or overrideScope' would work, and the other would warn or error, without a safe choice that always worked.

I'm generally okay with this change though

"`overrideScope` (from `lib.makeScope`) is deprecated. Do `overrideScope' (self: super: { … })` instead of `overrideScope (super: self: { … })`. All other overrides have the parameters in that order, including other definitions of `overrideScope`. This was the only definition violating the pattern."
(makeScope newScope (lib.fixedPoints.extends (lib.flip g) f));
overrideScope = g: makeScope newScope (lib.fixedPoints.extends g f);
# Add a warning after 23.11 and remove after 24.05.
Copy link
Member

Choose a reason for hiding this comment

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

I think the timing should be much more relaxed. Somebody could be using overrideScope while still using 23.05 and get the warning that it's deprecated and overrideScope' should be used, but then they upgrade to 24.05 on the same day and suddenly .overrideScope' is gone, even though they only upgraded by 2 release.

Copy link
Member Author

Choose a reason for hiding this comment

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

I meant remove it after 24.05 is branched off

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll tweak these, push coming soon.

Copy link

Choose a reason for hiding this comment

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

Agree. Looks like this was resolved in the latest push.

Copy link
Member

Choose a reason for hiding this comment

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

Not really: #248988 (comment)

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

LGTM. Looks like @infinisil's concern was addressed in the latest push.

Comment on lines 274 to 275
overrideScope' = g: lib.warn
"`overrideScope'` (from `lib.makeScope`) has been renamed to `overrideScope`."
Copy link
Member

Choose a reason for hiding this comment

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

I needs to use warnIf (isInOldestRelease 2311), such that we only warn once 23.11 isn't supported anymore, otherwise we still have the problem from #248988 (comment), because there wouldn't be a transition period where users could use both versions of the function.

Copy link
Member Author

Choose a reason for hiding this comment

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

#248988 (comment)

My plan now is to backport the first commit to 23.05 so users can support stable and unstable at the same time

Copy link
Member

@infinisil infinisil Aug 14, 2023

Choose a reason for hiding this comment

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

I don't think that's a great idea, because then you can't just check whether a release is 23.05 to figure out if overrideScope is fine to use, instead you have to make sure it's 23.05 after a specific commit/date.

Using warnIf (isInOldestRelease ..) without a backport would be my preference, it means 23.11 will be a clear boundary of when it changed.

And anyways, there's no need to hurry with this, let's take it slow

Copy link
Member Author

Choose a reason for hiding this comment

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

Uses warnIf now

(makeScope newScope (lib.fixedPoints.extends (lib.flip g) f));
overrideScope' = g: makeScope newScope (lib.fixedPoints.extends g f);
overrideScope = g: makeScope newScope (lib.fixedPoints.extends g f);
# Remove after 24.05 is released.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Remove after 24.05 is released.

Removal should definitely take a bunch longer! Otherwise somebody who's still used to using .overrideScope' updating from 23.11 to 24.11 would suddenly get an error!

Like yeah it can be removed at some point, but many people don't update to every NixOS release, and it doesn't cost us anything to leave the attribute in for some time.

This comment was marked as outdated.

…keScopeWithSplicing`

Right now converting `makeScope` to `makeScopeWithSplicing` is not
transparent to users and requires adding a warning for `overrideScope'`
in the set itself.

Warning and `overrideScope'` were added in 2018 b9dce11 and there should be no users left after 5 years.
`lib.makeScope` `overrideScope'` has been renamed to `overrideScope`

`fd --type f | xargs sd --string-mode "overrideScope'" "overrideScope"`
@Artturin Artturin merged commit 300da0a into NixOS:master Aug 14, 2023
4 checks passed
@Artturin Artturin deleted the matchoscopes branch August 14, 2023 15:56
@infinisil
Copy link
Member

infinisil commented Aug 14, 2023

Please don't self-merge when the PR is actively being reviewed and commented on..

(My approval happened at the exact same second as the merge, did you enable auto-merge?)

@Artturin
Copy link
Member Author

Please don't self-merge when the PR is actively being reviewed and commented on..

(My approval happened at the exact same second as the merge, did you enable auto-merge?)

Yes enabled auto merge

@infinisil
Copy link
Member

I see, I think that's okay then, though I still think self-merges should be avoided when possible (in this case I would've merged it for you)

@Artturin
Copy link
Member Author

Thanks for the reviews

@infinisil
Copy link
Member

infinisil commented Aug 14, 2023

The auto-merge turns out to be only possible due to this recent change: #249117 (comment)

@Artturin
Copy link
Member Author

Yeah, this was the first PR I saw it in and decided to try it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants