fetchMavenArtifact: fix metadata support#433975
Merged
Lassulus merged 1 commit intoNixOS:masterfrom Aug 20, 2025
Merged
Conversation
13 tasks
Fix fetchMavenArtifact to forward the "meta" attribute to mkDerivation rather than fetchurl.
48021e5 to
f81a2df
Compare
Lassulus
approved these changes
Aug 20, 2025
Contributor
|
Successfully created backport PR for |
1 task
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.
Fix
fetchMavenArtifactto forward the "meta" attribute tomkDerivationrather thanfetchurl.By fixing that issue, it adds support for the "meta" attribute of fetchMavenArtifact, making it usable as direct replacement for
stdenv.mkDerivationin 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-reviewon 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.