I am trying to run a super simple Clojure project in NixOS 23.05.
The project.clj file contains:
(defproject fsm "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.11.1"]
[com.phronemophobic/clj-graphviz "0.6.1"]]
:main ^:skip-aot fsm.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})
The file src/fsm/core.clj contains:
(ns fsm.core
(:gen-class))
(require '[com.phronemophobic.clj-graphviz :refer [render-graph]])
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!")
(render-graph {:edges [["a" "b"]]})
;; writes to graph.png
(render-graph {:edges [["a" "b"]]}
{:filename "my-graph.png"}))
But when I enter lein run, I get the error message:
Execution error (UnsatisfiedLinkError) at com.sun.jna.NativeLibrary/loadLibrary (NativeLibrary.java:323).
Unable to load library 'gvc':
libgvc.so: cannot open shared object file: No such file or directory
libgvc.so: cannot open shared object file: No such file or directory
Native library (linux-x86-64/libgvc.so) not found in resource path (...)
This works fine in other Linux distros (Pop OS!/Ubuntu), so I believe I am missing something with NixOS configuration. I am unfamiliar with this distribution.
libgvc.sois a part of GraphViz. You need to install GraphViz to get access to that library. Do so however you please.If you are not using Flakes for deploying/running your app, the easiest way to install GraphViz would be to use a Nix shell like so:
You can also add
graphvizto your installed packages list the same way you installedlein.