Nixpacks

Kinsta offers Nixpacks, an open-source project maintained by Railway, as one of the options to automatically create your application’s container image based on your repository. Nixpacks are scripts that are run when your application is deployed to install dependencies for your application and configure your environment.

We recommend using Nixpacks because they use less resources and support 20+ languages. You can choose Nixpacks when adding an application or by changing the Build environment option in application settings (Settings > Basic details > Edit details).

Supported Languages

Nixpacks supports the following languages:

  • Clojure
  • Cobol
  • Crystal
  • C#/.NET
  • Dart
  • Deno
  • Elixir
  • F#
  • Go
  • Haskell
  • Java
  • Lunatic
  • Node.js
  • PHP
  • Python
  • Rust
  • Swift
  • Scala
  • Zig

To use a different language version, set the version in your application’s files.

When using Nixpacks, there usually isn’t a need to choose or add different providers for the build because they are automatically detected. If additional providers are needed for the application, you can define those in a Nixpacks configuration file.

If you want to use a language that is not a supported Nixpacks or buildpacks language, you must use a Dockerfile. When you add your application, you can select the Use Dockerfile to set up container image option.

Configure Nixpacks

Some applications require no configuration, but some require specialized commands and options to run, such as:

Environment variables — You may need to set certain environment variables to run your application.

Processes — Kinsta can automatically detect your web process command. You can change this if required, and you can define additional processes.

Processes in a Procfile — You may want to define your processes in a Procfile within your application’s code.

Nixpacks Binary Directories

With Nixpacks, the binary directories may differ from the default binary directories for the application language. The following table shows the binary directories used for some of the most common languages:

LanguageDirectory
Node.js/nix/var/nix/profiles/default/bin/node
Ruby/nix/var/nix/profiles/default/bin/ruby
Python/nix/var/nix/profiles/default/bin/python
Java/nix/var/nix/profiles/default/bin/java
ScalaScala doesn’t have a specific default binary path like some other compiled languages. When you compile a Scala program, it generates bytecode that runs on the Java Virtual Machine (JVM).

The compiled Scala classes are typically stored in a directory structure that mirrors the package structure of your code. This is similar to how Java classes are organized. By default, when you compile a Scala source file, the compiled .class files will be placed in the same directory as the source code (within a subdirectory structure based on the package declarations).

If needed, you can install Scala’s runtime tools using a Dockerfile instead of using a Nixpack.

PHP/nix/var/nix/profiles/default/bin/php
GoGo doesn’t have a specific default binary path like some other compiled languages. When you compile a Go program, the resulting binary executable is typically placed in the same directory as your source code by default.

If needed, you can install Go’s runtime tools using a Dockerfile instead of using a Nixpack.

Set a Nixpack’s Language Version

When you select the option to Use Nixpacks to set up container image, if you do not specify a version in your application’s code, the Nixpack will use the latest available version. If you want to use a different language version for your application, you’ll need to set the version in your application’s files or, depending on the language, with an environment variable.

The available methods for setting the version vary by language. Below, we’ve included examples for the most common languages.

Go

To specify your Go version, include the following in your application’s go.mod file:

go 1.18

Java

To specify your Java version, set the NIXPACKS_JDK_VERSIONenvironment variable and make sure the variable is available during the build process.

If you’re using Gradle, to specify the version, set the NIXPACKS_GRADLE_VERSIONenvironment variable and make sure the variable is available during the build process.

Node.js

To specify your Node.js version, do one of the following:

Include the following in your application’s package.json file:

"engines": {
"node": "18"
}

Or, set the NIXPACKS_NODE_VERSIONenvironment variable and make sure the variable is available during the build process.

PHP

To specify your PHP version, include the following in your application’s composer.json file:

{
  "require": {
    "php": "8.2"
  }
}

Python

To specify your Python version, do one of the following:

  • Include the following in your application’s runtime.txt file:
    python-3.10.6
  • Include the following in a .python-version file in your repository:
    3.10.6
  • Set the NIXPACKS_PYTHON_VERSIONenvironment variable and make sure the variable is available during the build process.

Scala

To specify your Scala version, include the following in your application’s build.sbt file:

scalaVersion := "3.2.2"
Was this article helpful?