I’m trying to create a Clojure binary with clj-nix, but I’m a bit stuck.
The binary I’m creating depends on a library I created, which uses a combination of Clojure & Java code. That requires the use of tools.build to create the jar. I can build the lib successfully, and once installed in the local maven cache I’m able to use it in the binary package.
However…I can’t figure out how to add the dependency to the binary’s
deps.edn in such a way that
clj-nix can make use of it.
I don’t really want to publish the lib to an official Maven repo, or set up my own. Local caches don’t (and shouldn’t) work. If I use a
:git dep instead of
:mvn, I don’t think I can specify how the package should be built, and the default build only includes the Clojure source, so it fails at runtime due to missing Java classes.
The most elegant way to solve this would seem to be using clj2nix’s
mkCljLib package to generate a jar file, and using that directly. The existence of that function seems to suggest that could be a possibility, but I haven’t found any examples where that’s done, and there’s a timing problem: clj-nix uses
deps.edn to determine the dependencies, but libraries created by
mkCljLib don’t exist yet when I’m writing the
Has anyone found an elegant solution to this problem? Including dependencies in the form of flakes seems like the ideal thing to do, but that doesn’t really work with
deps.edn, especially in a way that plays nicely with other Clojure tools like Cider. Is there some function I missed to include the library from a flake into the class path of the build or something?