-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
[RFC] Hash overriding of fetcher-constructed FODs? #459651
Copy link
Copy link
Open
Labels
0.kind: enhancementAdd something new or improve an existing system.Add something new or improve an existing system.1.severity: significantNovel ideas, large API changes, notable refactorings, issues with RFC potential, etc.Novel ideas, large API changes, notable refactorings, issues with RFC potential, etc.9.needs: community feedbackThis needs feedback from more community members.This needs feedback from more community members.
Description
Background
The adoption of fixed-point arguments (finalAttrs: { }) is enabling us to override fetcher arguments with standard <pkg>.overrideAttrs instead of custom, locally-added override.
Most fetchers support the hash argument to specify FOD hashes with SRI hashes or optionally an empty string, while current fetcher implementation typically exposes only the derivation attributes outputHash, and its siblings outputHashAlgo and outputHashMode to <pkg>.overrideAttrs.
There are another kind of fetchers which returns a wrapper of an FOD rather than the FOD itself. For instance, rustPlatform.fetchCargoVendor first creates the vendorStaging FOD and then return a derivation wrapping the FOD. I refer to them as "wrapped fetchers" in the following questions.
Questions
- Should we override fetcher hashes with
<pkg>.overrideHash?- (+) Custom overriders (like
overridePythonAttrs) are causing enough problems. The unified<pkg>.overrideAttrsis the way. - (-) Custom
overridefor fetcher results inherently have an interface identical to the fetcher itself.- (+) We could also make
<pkg>.overrideAttrsaccepthashand push similar changes to unify significant part of the<fetched-pkg>.overrideAttrsarguments toward those used by the fetcher itself.
- (+) We could also make
- (-)
<pkg>.overrideAttrsdoesn't white-list the overriding arguments and is prone to typos.- (+) We can implement optional checks to white-list the attributes.
- (-) For fetchers like
fetchFromGitHubthat dynamically switch between base fetchers (fetchgitandfetchzip), it is hard to implement the dynamic switching functionality for<pkg>.overrideAttrs.- (+) It is possible to implement ( fetchFromGitProvider: init (optional dynamically switchable after
<pkg>.overrideAttrs) #462034 ), but at significant performance overhead. - (+) We could implement manual switch via
fetchFromGitHub.override.
- (+) It is possible to implement ( fetchFromGitProvider: init (optional dynamically switchable after
- (+) Custom overriders (like
- Should we make
hashoverridable with<pkg>.overrideAttrs, or should we keep overridingoutputHash?- (-) Every FOD has
outputHash. Its overriding functionality is 100% backward compatible and mostly available. - (+) Making
hashoverridable is more intuitive and consistent with fetchers' interfaces. - (+) Making
hashoverridable allowsoutputHash = if finalAttrs.hash == "" then lib.fakeHash else finalAttrs.hash, making it easy to determine the hash withhash = ""and make the hash algorithm future proof when specifying empty hashes. - (+) This exposes
src.hash, which sounds more intuitive thansrc.outputHash.- (-) We already have
src.outputHash.
- (-) We already have
- (-) Every FOD has
- If we choose to override
hash, should we also expose thehashattribute of wrapped fetchers's direct result attribute, or should we instruct the user to override the hash by overriding the inner FOD?- (-) Just instruct people to override the inner FOD, as they have to when overriding other attributes.
- (+)
hashis special to fetchers, and it's important to ensuresrc.overrideAttrs { hash = ...; }always work.
Related issues and PRs
- Impossible to override arguments of rustPlatform.fetchCargoVendor #415397
- fetchhg: fix hash assertion; make overridable when sha256 set #423877 (This is what it looks like to make
hashoverridable.) - fetchurl: fix overrideAttrs working as expect with hash #459487
- Documentation: guide for using
let invsrecvsfinalAttrs#315337
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
0.kind: enhancementAdd something new or improve an existing system.Add something new or improve an existing system.1.severity: significantNovel ideas, large API changes, notable refactorings, issues with RFC potential, etc.Novel ideas, large API changes, notable refactorings, issues with RFC potential, etc.9.needs: community feedbackThis needs feedback from more community members.This needs feedback from more community members.