Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Nix resolver to SBT #7

Open
charleso opened this issue Aug 9, 2014 · 5 comments
Open

Add Nix resolver to SBT #7

charleso opened this issue Aug 9, 2014 · 5 comments

Comments

@charleso
Copy link
Owner

charleso commented Aug 9, 2014

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!

@charleso
Copy link
Owner Author

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:

  1. Write a specific Nix SBT resolver that looks in the surrounding environment and resolves packages appropriately.
  2. Generate a separate build.sbt on-the-fly with the relevant details. I really don't like this option as it's very prone to breakage between SBT versions.
  3. Generate a separate/temporary repository by symlinking to nix artifacts and then set the -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.

@puffnfresh
Copy link
Collaborator

Generate a heap of symlinks under the unmanaged jars directory. Skip Ivy.

@coreyoconnor
Copy link

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:

  • populate a coursier cache directory with dependencies
  • set COURSIER_CACHE
  • force sbt to include coursier plugin
  • build using sbt

@charleso
Copy link
Owner Author

@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. :)

@cessationoftime
Copy link

cessationoftime commented Dec 11, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants