Closed volisoft closed 1 month ago
thanks for the example project, looks like a bug, I'll take a look
I was playing with polylith, and the way to build an uberjar is a bit different, it doesn't work with the default clj-nix builder, but that has nothing to do with :local/root
(which are supported by clj-nix
)
As an example, you can see how to build a polylith project with clj-nix here:
https://github.com/jlesquembre/usermanager-example
Run:
nix build .
result/bin/main
Take a look at the flake.nix
file: https://github.com/jlesquembre/usermanager-example/commit/e4a71afbd3a86092d9b9ee8500d61fc20b9b4715
Notice that flake.nix
needs to be at the root of the project, and that we need a custom build.clj
file.
Maybe we could try to add support for polylith, to avoid the need for a custom build.clj
file.
Thank you for taking a look. Is it possible to keep flake.nix in the projects
directory?
In my actual repository there's already a flake.nix in the project's root, which sets up development tools.
Also, potentially, there can be multiple separate projects under projects
directory, each with it's own assets and build process.
Is it possible to keep flake.nix in the projects directory?
It is, but instead of doing that, I'd create multiple packages within the flake, something like this:
packages = {
webapp = clj-nix.lib.mkCljApp ...;
cliapp = clj-nix.lib.mkCljApp ...;
};
if your repository is open source, could you share a link to it?
That looks interesting. Will each project require a separate deps.lock file? If so, should the lock files be placed in the appropriate project's directory?
I'm afraid the repository I'm working with is private, so I cannot share it. However, it's a typical Polylith mono-repository. I can add another sub-project to the demo project if you need something for testing.
You only need one deps.lock
file. clj-nix
looks for all deps.edn
files in the repository. You can include/exclude certain files and aliases. For details, see:
https://jlesquembre.github.io/clj-nix/lock-file/
That works. Thank you for your help!
@volisoft I'd like to play around with Polylith, and maybe add support for it in clj-nix. However, given the flexibility of Polylith, it might be more practical to provide a custom build.clj
.
I believe build.clj
is a suitable solution. Since others may encounter this situation as well, adding a hint in the documentation pointing to this solution could be very helpful.
Seems like relative paths in
:local/root
are not supported. Here's an example project. Here's the error indicating that local library at../../components/liba
cannot be found:Such relative paths are supported by Clojure deps and are common in polylith projects.
Originally posted by @volisoft in https://github.com/jlesquembre/clj-nix/issues/7#issuecomment-2282244478