fetchMavenArtifact: fix metadata support #433975
Merged
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.
Fix
fetchMavenArtifact
to forward the "meta" attribute tomkDerivation
rather thanfetchurl
.By fixing that issue, it adds support for the "meta" attribute of fetchMavenArtifact, making it usable as direct replacement for
stdenv.mkDerivation
in most cases.Background: For many Java packages, the derivation created by fetchMavenArtifact is wrapped into another derivation that copies over all files, just to be able to specify the metadata via the "meta" attribute in the outer derivation. This is cumbersome, because it is extra code that is unnecessarily convoluted. And it is wasteful, as all downloaded JAR files are stored twice into the Nix store, for the outer and the inner derivation, until the next "gc" or "optimize" action happens.
Solution: All those derivations could instead be created by a single call to fetchMavenArtifact, without copying their downloaded JAR files twice into the Nix store, if fetchMavenArtifact would just forward the "meta" attribute properly. This commit does exactly that.
See PR #427538 for an example on how simple Java derivations from Maven Artifacts can be:
Also, reusing pieces of another package, such as its version number or most of it metadata, works the exact same way as we are used to with
stdenv.mkDerivation
:Again, see PR #427538 for a practical example of reusing metadata.
Things done
passthru.tests
.nixpkgs-review
on this PR. See nixpkgs-review usage../result/bin/
.junixsocket-*
packages, see PR junixsocket{,-native}-common: init at 2.10.1 #427538)Add a 👍 reaction to pull requests you find important.