fetchgit, fetchFromGitHub: preserve attributes through overrideAttrs#455637
fetchgit, fetchFromGitHub: preserve attributes through overrideAttrs#455637adeci wants to merge 2 commits intoNixOS:masterfrom
Conversation
|
| # Allow other attributes to pass through | ||
| ... | ||
| }@args: |
There was a problem hiding this comment.
This allows (but ignores) additional arguments -- args isn't used anywhere so any of the arguments not explicitly listed are lost. Not sure if that's the intention.
There was a problem hiding this comment.
You're right that @args isn't used, so any extra arguments beyond the explicitly listed ones (and passthru) are dropped. This is intentional since we only need to:
- Accept extra arguments without error (via
...) - Pass through
passthruspecifically (which we merge)
I also figured it may be best to drop everything not explicitly listed since passing all arbitrary arguments to mkDerivation could actually be risky, like setting builder or outputHash, etc.
Do you think it's best to remove @args?
There was a problem hiding this comment.
I think removing args would make the intention to drop other arguments clearer.
Since binding the arguments to a variable allows you to access the arguments which weren’t declared (since you’re using no …), I assumed that you were going to use args in some way (conditional logic, filtering it and passing it on, etc.).
There was a problem hiding this comment.
Why adding ellipsis? Functions with ellipsis are prone to misspelled/unsupported argument names.
There was a problem hiding this comment.
I had @args originally to follow fetchzip's pattern, as it passes extra args through to fetchurl via removeAttrs, however while I did the same we only explicitly handle passthru instead of passing all args to mkDerivation. The difference here is that while fetchzip passes to another fetcher (fetchurl), fetchgit is passing directly to mkDerivation. I think it is a good idea to remove @args here like @ConnorBaker suggests for clarity and since we aren't using it for any logic later down the line.
Why adding ellipsis? Functions with ellipsis are prone to misspelled/unsupported argument names.
Regarding the ellipsis you're right it is prone to typo risks and we could remove it and only address what we need with passthru ? {}, but keeping it is consistent with fetchzip and allows for future flexibility if we later need to pass other attributes like custom meta etc.
I will remove ... since we don't immediately have any use for other attributes within fetchgit.
|
cc @ShamrockLee – perhaps using Edit: whoops, Philip beat me to it. |
I believe because @ShamrockLee actually covered precisely this here: I think we'd have to modify both |
Your proposal inspires me to reconsider its possibility. As both Considering that
We can formulate both Given that The Update:
|
|
@emilazy The BTW, there are at least three competing implementation addressing this issue. The other two are: |
|
I dropped
We all take a similar approach, #294329 never included
@ShamrockLee your
This provides all of the above, and with |
|
@adeci My apology for being rude in my previous comment. Build helpers with ellipses are surely more flexible, and ellipses are necessary to define a build helper with a A down side of passing arguments (say If you are adding an ellipsis to pass arguments from the derived fetchers down the |
|
Closing, succeeded by #456751 |
|
I updated the composition expression in my above comment to fix an error and add a working code to rewrite the metadata of a build helpers to base on |
Taking a stab at this after seeing it, hopefully fixes #444503.
When using
overrideAttrson a derivation fromfetchFromGitHub, attributes likeowner,repo, andrevwere lost. This particularly affected derivations using the fetchgit backend (whenleaveDotGit = true,fetchSubmodules = true, etc.).Things done
Following the idea from @ConnorBaker to have the fetcher implementation accept variable arguments and pass through those which are not explicitly used:
passthruparameter and arbitrary arguments via..., matching fetchzip's behaviorpassthruto ensure they surviveoverrideAttrsTesting
Tests passed:
nix-build . -A tests.fetchFromGitHub --no-out-linknix-build . -A tests.fetchgit --no-out-linkoverrideAttrsissueExpand for custom test
Before this PR:
After this PR:
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.