Help packaging a Java app?

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? :slight_smile:


If the app has little number of dependencies to download, you can model your code after processing ( (it uses ant but there is no big difference, just replace ant build with mvn package)

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.

  1. Maven can be run twice, the first time to download all dependencies into fixed-output derivation and the second for the offline build (example 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)
  2. Make a big list of all dependencies (example Disadvantage: difficult to maintain and update. This is where tools like mvn2nix are suppose to help.
  3. Mixes of the two approaches above (example:

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.


This github issue documents the problem somewhat, and discusses some alternatives:

Thanks for the tips, folks! I’ll let you know how it goes.