Maintained/usable tooling for building Clojure projects in Nix?


#1

I’m trying to understand how to build Clojure projects in Nix. There are two major build tools in the Clojure world – Leiningen and Boot. Both support Maven-style dependency resolution and download – and Boot is actually distributed as a bootstrap tool that downloads Boot itself from public Maven repositories, and expects to find its own jars in the user’s Maven cache in their home directory.

Somewhat disturbingly, the Nixpkgs package for Boot distributes that bootstrap tool only, and does not include Boot itself; consequently, it cannot be used from any sandboxed environment such as nixbld (unless one creates a home directory with a local Maven cache and populates it with the jar for the actual version of Boot that project is configured to use).

Nixpkgs includes buildMaven, which attempts to build a repository with all JARs specified for a given pom.xml. This depends on a Maven plugin generating a JSON file describing the set of jars and their download locations; a nix2mvn Maven plugin is used to generate this file. However – pending merge of NixOS/mvn2nix-maven-plugin#18 – that plugin doesn’t correctly handle pom.xml files with trailing /s in repository locations (as created by Leiningen – POMs from Boot don’t have this issue). It also appears not to be able to find URLs for artifacts which are in its own runtime environment..

There also exists a boot2nix tool, “a Boot task to generate Nix expressions”. However, even when configured with a repository URL and able to resolve to the coordinates of same, it’s unable to find download URLs of some publicly-available artifacts – notably including [com.googlecode/jsendnsca-core "1.3.1"] (which is canonically located in Red Hat’s Maven repository, rather than Maven Central). Its maintainership would welcome a PR for this, but I’ve yet to be able to run down a root cause for the issue.

As a Clojure-centric alternative to depending on the mvn2nix Maven plugin, dwn is another project which appears promising (having a full README and a clean set of bindings to the underlying “Aether” / “Apache Maven Resolver” library used by Leiningen, Boot and Maven to resolve and download dependencies); however, even when updated to use the very latest version of that library, it’s unable to find URLs for the same projects for which boot2nix fails above. (dwn also gives a distinct impression of being a work-in-progress; some components are very usable as-is, but other namespaces don’t even compile/load).

Have other folks trod this ground? Is there any consensus around production-ready tooling?


To run over the projects discussed above once more, in more condensed form:

  • <nixpkgs>.buildMaven - Depends on mvn2nix to build a JSON description of build artifact sources; latter misses some packages (ones overlapping its own dependency chain?)
  • boot2nix - Misses a different set of packages (jsendnsca-core).
  • dwn - successor to lein-nix; contains an independently-written Aether wrapper in Clojure; misses the same packages as boot2nix.

#2

Issue 19741 “Maven builds are not documented in nixpgs manual” has some discussion of the shortcomings of mvn2nix and a shell script alternative.

There are definitely some rough edges around Java build tooling that could use some TLC. :-/