Currently sbt projects are supported for Scala. For gradle and maven support, please look at Java. Scala is detected by
build.sbt in project root.
The following major JDK versions are available
The version can be overridden by setting the
NIXPACKS_JDK_VERSION environment variable.
The project should contain the
sbt-native-packager sbt plugin. This can be done by adding the plugin to
// Check https://github.com/sbt/sbt-native-packager for version addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "x.x.x")
After that enable the
JavaAppPackaging plugin in
build.sbt and set the
main. An example of the
build.sbt can be seen here.
val scala3Version = "3.2.2" lazy val root = project .in(file(".")) .settings( name := "scala-sbt", version := "0.1.0-SNAPSHOT", scalaVersion := scala3Version, // This is required by nixpacks executableScriptName := "main" ) // sbt-native-packager is the tool used by nixpacks // to generate the package .enablePlugins(JavaAppPackaging)
executableScriptName is required for
nixpacks to run the right executable in the start command.
sbt-native-package is used for building the package.
This creates the required packages and also a convenient script to run at
Run the built script:
The script picks up
JAVA_OPTS to provide jvm or java arguments to the system.