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.

SBT Setup#


The following major JDK versions are available

  • 21
  • 20
  • 19
  • 17 (Default)
  • 11
  • 8

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 project/plugins.sbt.

// Check for version
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "x.x.x")

After that enable the JavaAppPackaging plugin in build.sbt and set the executableScriptName to main. An example of the build.sbt can be seen here.

val scala3Version = "3.2.2"

lazy val root = project
    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

The executableScriptName is required for nixpacks to run the right executable in the start command.


sbt-native-package is used for building the package.

sbt stage

This creates the required packages and also a convenient script to run at ./target/universal/stage/bin/main


Run the built script:


The script picks up JAVA_OPTS to provide jvm or java arguments to the system.