Make callPackage observe <pkg>.override.argSelectors and by-name-overlay manage arg-selectors.nix and siblings#455805
Draft
ShamrockLee wants to merge 6 commits intoNixOS:masterfrom
Draft
Make callPackage observe <pkg>.override.argSelectors and by-name-overlay manage arg-selectors.nix and siblings#455805ShamrockLee wants to merge 6 commits intoNixOS:masterfrom
<pkg>.override.argSelectors and by-name-overlay manage arg-selectors.nix and siblings#455805ShamrockLee wants to merge 6 commits intoNixOS:masterfrom
Conversation
<pkg>.override.argSelectors and by-name-overlay manage arg-selectors.nix and siblings
a83df8b to
a861725
Compare
Member
|
(ccing myself as highly relevant to my goals for 26.05! I think the cumulative desiderata for a full migration of everything to |
a861725 to
f71e370
Compare
f71e370 to
c4814d4
Compare
Contributor
Author
|
Rebased for the CI fixes. See #457845 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Introduce
argSelectorsas a way to specify arguments for the override interface.It is an attribute set of functions that takes
pkgsand return the selected argument.The difference between the
argSelectorsand thepkgs: { ... }args.nixproposed as an alternative enhancement in Nix RFC 140 is that the attribute names ofargSelectorsis strict and accessible without calling the selector functions.Teach
lib.callPackageWith autoArgs f argsandlib.callPackagesWith autoArgs f argsto observef.<argSelectors>, and attachargSelectorsto the result as<pkg>.override.argSelectorsifargs == { }.This ensures that
argSecetorswill be lost after calling<pkg>.overridedirectly or after specifying a plain attrset of custom arguments tocallPackage. The presence of<pkg>.override.argSelectorstherefore ensuresresult == pkgs.callPackage result.override { }.This is useful to short-cut the build tests of staging changes. If the mass-rebuild change of
pkgs.foocause its direct dependentpkgs.barto rebuild, andpkgs.bar.override.argSelectorsis present, its rebuild can be short-cut asProvide
lib.makeCallPackageWithArgSelectorsandpkgs.callPackageWithArgSelectorsas a convenient way to add/extend<pkg>.override.argSelectors.Teach the
by-name-overlay.nixto understand an optional filearg-selector.nixbesidepackage.nix, implementing the "Option 3" of Fixing.overrideinterface stability #404946.Even though the hard-coded version-specific override interface proposed in pkgs/by-name/README: explicitly suggest version specific override interfaces #444420 enhances override stability, we sometimes do want override abstraction for interoperability. For example, we may want different versions/variants of a package (e.g.
foo,fooMinimalandfooFull) to have the same override interface to make it possible tobar.override { foo = foo_1; }. Thesibling.nixinterface proposed below makes it possible to define them inpkgs/by-name.Introduce a way to specify "siblings" inn
pkgs/by-name. One can define a sibling with apackages.nixin the following format:A sibling can also have an optional
arg-selectors.nixfor<pkg>.overrideoverriding.The above example provides
foo-minimalwith the same<pkg>.overrideinterface aspkgs.foothe following way:The sibling design is inspired by lib.makeAlias: init with by-name support #442066
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.