jlesquembre / clj-nix

Nix helpers for Clojure projects
https://jlesquembre.github.io/clj-nix/
Eclipse Public License 2.0
138 stars 19 forks source link

How to build using a non-headless JDK? #114

Open ships opened 5 months ago

ships commented 5 months ago

Hi friend, thanks so much for this package which promises to seriously solve some problems I am facing with making reproducible clojure environment! I really agree with much of the design sensibility.

I am encountering a problem that may be a bug but since I'm newish to this ecosystem there is also a chance I have simply misconfigured.

The issue is that I try to compile with openjdk17, not headless, because my application requires non-headless capabilities:

        cljNixApp = clj-nix.lib.mkCljApp {
          inherit pkgs;
          modules = [
            # Option list:
            # https://jlesquembre.github.io/clj-nix/options/
            {
              projectSrc = ./.;
              name = "inferenceql.query";
              main-ns = "inferenceql.query.main";

              # the important directive
              jdk = pkgs.openjdk17;
            }
          ];
        };

However, i still get an error in the clojure compile log like this: "Execution error (HeadlessException) at sun.awt.HeadlessToolkit/getMenuShortcutKeyMask (HeadlessToolkit.java:135).\n\nThe applicati on is not running in a desktop session,\nbut this program performed an operation which requires it.\n"

and so on. I don't expect headlessness at any point here, so I'm curious if i'm failing to specify it correctly. I notice that in various places in test and documentation i see the word jdkRunner rather than jdk =, but when I try that, clj-nix complains there is no such option.

Thanks again for your project & your guidance! Happy to contribute as I am able.

ships commented 5 months ago

Ah, I found a Slack thread where you provided related thoughts to this very project that I will explore and report back here what i find: https://clojurians.slack.com/archives/C02S1GEKU4C/p1701988611734399

ships commented 5 months ago

Okay, having circled back, I wasn't able to solve this issue directly but my workaround is definitely workable for me: we use mk-deps-cache to generate a deps cache from the deps-lock.json and then pass that as an input to the uberjar build step, which uses native clojure instead of mkCljBin.