Open charleso opened 10 years ago
So cabal2nix
basically wraps the ghci
command with a script that dynamically adds the relevant -package-db
flags based on the current $PATH
which includes anything with .installedconf
. See wrapper.nix.
I don't think doing this for SBT is going to be quite as simple. A few options come to mind:
-Dsbt.override.build.repos=true
and -Dsbt.repository.config
flags.http://www.scala-sbt.org/0.13/docs/Proxy-Repositories.html
Regardless of these options we would almost certainly need to keep a copy of the relevant ivy file (or equivalent) for each dependency to make the connection between Nix artifact and org/module/version.
Suggestions welcome.
Generate a heap of symlinks under the unmanaged jars directory. Skip Ivy.
I was reading through the coursier resolver docs and source
This has similar aspects that might be usable. In particular the cache only mode. From what I can read, Coursier uses this to implement a sandbox mode: isolated dependencies tree without requiring network access.
At least "chances are" that's what it enables: "If all your dependencies are in cache, chances are coursier will not even try to connect to remote repositories"
The layout of cache directory is a fairly obvious map of upstream / package / version. A quick hack might be:
@coreyoconnor Thanks for the suggestion. However, I feel like that would be more complicated than just generating the unmanaged jar symlinks like Brian suggested. Nix is doing the rest anyway.
That said, it's not like I'm actually actively doing anything on this project, so feel free to ignore me. :)
https://github.com/teozkr/Sbtix currently has an implementation that makes use of https://github.com/alexarchambault/coursier and pretty nearly does what coreyoconnor suggests. The coursier cache directory isn't populated with dependencies directly, instead sbt is given access to a local repo of dependencies which have been found by coursier and cached by nix-prefetch-url
.
So we can take advantage of all the goodies that SBT has, and in particular incremental compilation. Without this the initial dev experience is going to suffer in Nix (I suspect).
It's probably a good idea to look at how cabal2nix solves this with with
nix-shell
. It maybe easier than I think, but I'm not sure.The sooner we get this the better (and more useful) this plugin is going to be!