-
-
Notifications
You must be signed in to change notification settings - Fork 17.7k
pkgs/README.md: discourage overrideAttrs within Nixpkgs #421201
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why we wouldn't allow them for the specific use case of defining versioned attributes. Should we rather duplicate an entire expression even if only version and hash need to be changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to introduce an
.overrideparameter to select between the versions, or to have some other internal logic for it like a generic builder function. Actually I can’t remember seeing many instances ofoverrideAttrsbeing used this way at all; maybe it’s more common in the Python package set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also already addressed in the text, and it does not say to duplicate an entire expression:
I'm open to feedback on that advice though! I agree with Emily that it's not common for centralized version overrides of packages (as opposed to sneaky hidden overrides in leaf packages) to use overrideAttrs in the first place. Again, if overridePythonAttrs is different, I'd be happy to exclude it and just address overrideAttrs for the time being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's an example:
nixpkgs/pkgs/top-level/python-packages.nix
Lines 3189 to 3197 in 30db601
I prefer to keep using
overridePythonAttrshere because we'll soon get rid ofcython_3_1again and I don't want to go back an forth between a normal expression and one that uses a "function that can build multiple versions of the package".I also don't see why this situation would be unique to Python packages, see e.g.
nixpkgs/pkgs/by-name/ni/nim-unwrapped-2_0/package.nix
Lines 8 to 10 in 30db601
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about cython, but for things like compilers and interpreters more generally, my experience is that we are either consistently strict about only packaging a single version (like Rust), or we are open to packaging multiple versions, and usually do. In the latter case, I'd keep the generic function around even if there happens to only be a single version packaged for some amount of time, since it's likely that in the near future there will again be multiple versions. Nim looks like it would be one of those situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I thought you meant
overrideAttrs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alyssais Maybe we should remove the verbiage about avoiding copy‐paste here? It’s generally better to do, but it’s not related to
overrideAttrsspecifically, and I feel there are some cases whereoverrideAttrsavoidance is most easily accomplished by copy‐paste (cf. the vendored package example in my tl;dr comment).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which verbiage specifically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I misread it the first time I think. But I think we can make this paragraph more generic by just mentioning packaging the other version and not being prescriptive about how:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. You're both right that there's no one-size-fits-all approach here, so I've made it more vague.