-
-
Notifications
You must be signed in to change notification settings - Fork 19k
replaceVars.withoutCheck: init #339303
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
Closed
Closed
replaceVars.withoutCheck: init #339303
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
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
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
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 understand how this works.
(x: x) // { }is an error. Is this some__functormagic? I think I would prefer something likereplaceVarsWith { doCheck = false; } ./file { … }, wherereplaceVars = replaceVarsWith { }.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.
Yes, kind of. An attrset with
__functoris also just an attrset.It's used a couple places in
all-packages.nix: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'll note that
callPackageis used in cases like this where it doesn't actually resolve to a package, but rather to a factory function that will then produce packages/derivations. If there were something like acallPackageFactoryfunction that included the ability to passthru additional contents, this would look quite a bit more sane.The core piece of code that's creating this functor attrset is
nixpkgs/lib/customisation.nix
Line 264 in 4e2566e
As it is, I'm pretty sure that this specific feature doesn't yet justify
replaceVarsWith, but if you feel quite strongly, I could introduce it.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.
Right, I figured
callPackagemight be doing something like this. I just think__functoris weird and people don’t expect to find more functions under a function.The nice thing about
replaceVarsWithis that it would compose with any future extensions, like if we want to supportpostPatchor something. If you’re totally sure that there’ll never be another option ever again then maybe it could just bereplaceVarsWithoutCheck?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.
One of the reasons I tilted this (odd) way was that I was able to document this variant "under"
replaceVarsso that it appeared in context on https://noogle.dev/f/pkgs/replaceVars. That documentation outweighs the oddity of people finding or failing to find functions under a function... I think. 😁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 agree with @emilazy that
__functorshould be avoided when possible, it can be very confusing. I like the idea ofreplaceVarsWithmore, especially because the same pattern is being used elsewhere too. Check out the docs forlib.fileset.gitTrackedas an example how such a pair of functions can be crosslinked together in the docs, but nesting one under the other would also be fine imo.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.
All right, I'll do
replaceVarsWith.