Open Source Docs

Sbtix

Reproducible Nix builds for sbt projects

FAQ

Common questions about Play Framework, git deps, and default.nix


FAQ

Q: Why I am getting errors trying to generate repo.nix files when using the PlayFramework?

A: You probably need to add the following resolver to your project for Sbtix to find.

// if using PlayFramework
resolvers += Resolver.url(
  "sbt-plugin-releases",
  url("https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/")
)(Resolver.ivyStylePatterns)

Q: When I nix-build it sbt complains java.io.IOException: Cannot run program "git": error=2, No such file or directory

A: You are likely depending on a project via git. This is not recommended because it can make builds non-deterministic. Prefer replacing the git dependency with a pinned source dependency or a normal repository artifact. If your build really needs to shell out to git, pass it as a build input in your Nix expression:

sbtix.buildSbtProgram {
  # ...
  buildInputs = [ pkgs.git ];
}

Q: How do I keep my own default.nix?

A: Keep your own default.nix in the project. genComposition writes sbtix-generated.nix every time, but it only writes an example default.nix when one does not already exist.

Q: How do I use a different type of SBT build in default.nix

A: The generated composition uses sbtix.buildSbtProgram, which expects a stage task. For libraries, call sbtix.buildSbtLibrary directly from your own default.nix; for custom layouts, call sbtix.buildSbtProject with an explicit installPhase.