I’d like to package Rachota, a timetracking app. I see that it’s designed to be built with Maven, but I don’t know the first thing about that tool (or Java development in general). I also see that there are no Nixpkgs docs about using maven, and that there are a two(?) functions for building maven projects in nixpkgs code base. One of them requires a secondary tool, mvn2nix. It is not immediately clear to me how to use any of these tools, and there aren’t any examples to crib off of in the nixpkgs repo.
Could someone point me to examples of Maven-built packages that would be good to copy from? Or give me pointers of any sort?
If there is a lot of jars to download from maven cental, then it is a problem which has many solutions. none of them is perfect.
Maven can be run twice, the first time to download all dependencies into fixed-output derivation and the second for the offline build (example https://github.com/NixOS/nixpkgs/blob/44aca430c3745c8a5de75afc7b170f5dc0e21bd0/pkgs/applications/science/misc/gephi/default.nix). Disadvantage: outputHash of the FOD is drifting with time and will need to be updated in few months (because maven dependencies can refer to “latest” vesrion of some artifact, and when the artifact is updated, the output of the phase is changed)
As I wrote in Shell.nix or default.nix for java project I have used Mavenix for some projects at work and was quite happy with the experience. Mavenix creates a lock file and a Nix expression. The latter can be modified, however, one needs to be careful because it may break the script that is used to update the lock file. There were some issues but together with the maintainer of Mavenix those were resolved quite quickly. Unfortunately I do not have any public projects to share.
POM files might refer to version ranges instead of exact versions.
For example hadoop depends on jodatime “at least 2.9”, and with every new jodatime release Maven (the 1st pass) picks the latest version, producing different output with different sha256
@volth although pom files technically could specify a version range:
1 - it’s quite uncommon
2 - the solution I proposes first builds an “effective-pom.xml” which is a pom file with all the dependencies pinned down. The solution uses the same dependency traversing algorithm as Maven (by using Maven’s internal libraries) to figure out the actual closure that will be resolved.
@doronbehar I will send a PR with some content I have created for the nixos-weekly
@volth your comment about snapshot of whole Maven central had me thinking about “multiple output derivations”
I had a crazy idea to create a single derivatoin for “mvncentral” which is a multiple output derivation for each individual JAR One could specify the output of a subfolder for the organizations you wanted to pull in.