Clj-nix: Nix helpers for Clojure applications

I’m happy to announce clj-nix: GitHub - jlesquembre/clj-nix: Nix helpers for Clojure projects

The main goal of the project it’s to make easier to package Clojure projects with Nix.
To accomplish that, it provides some Nix functions to create binaries, optimized JDK runtimes and GraalVM native images.

The project it’s just starting, the API would probably change. Feedback is very welcome.

I hope you find it useful.

6 Likes

wonderful thank you!

i see it supports tools.deps, but not Leiningen? If so, adding support for the latter would be most beneficial to packaging Clojure projects that still use that. For example, I was looking into packaging https://github.com/protojure/protoc-plugin into Nix, but can’t really find any example on doing that for Leiningen.

Leiningen is not supported, but I’ll try to add support for mixed Leiningen-tools.deps projects (like for example babashka)

I didn’t plan to add support for pure Leiningen projects, but you could create a deps.edn from the project.clj (I think there are projects to automatically generate one from the other, but I’m not 100% sure), and then you could use clj-nix

1 Like

@yuu
I added support for pure Leiningen projects, changes are on the main branch.

To generate a lock file run nix run github:jlesquembre/clj-nix#deps-lock -- --lein, you should be able to build the project with something similar to this:

mkCljBin {
  projectSrc = ./.;
  buildCommand = "lein uberjar";
  # ...
}

While it’s not required to have a deps.edn, it’s recommended, see https://github.com/jlesquembre/clj-nix#leiningen

3 Likes
Hosted by Flying Circus.