Configuration File#

Nixpacks has experimental support for specifying build configuration in a nixpacks.toml or nixpacks.json file. The config will automatically be used if one of these files is found in the app root. Otherwise, the file can be specified with the --config <file> flag or with the NIXPACKS_CONFIG_FILE environment variable.

The contents of this file can contain a full build plan, which means that every aspect of the build can be customized. An example config looks something like:

# nixpacks.toml

nixPkgs = ['...', 'cowsay']

cmds = ['yarn run server:build']

cmd = 'yarn run server:start'

The file-based build plan is merged with the build plan generated by the provider, as well as the configuration from the environment variables and CLI flags. By default values are overridden when merged if they are not null. The configuration priority is

  • Provider (lowest)
  • File
  • Environment
  • CLI

Array Extending#

The default behaviour when merging build plans is for a non-null value of higher priority to override a lower priority value. However, you can use the "..." special syntax to extend the values in an array. For example:

# Build plan from the provider
nixPkgs = ['nodejs', 'yarn']

# nixpacks.toml
nixPkgs = ['...', 'cowsay']

# Merged plan
nixPkgs = ['nodejs', 'yarn', 'cowsay']

The "..." represents a hole that will be populated by the values from plan that is merged into.

Build image#

The image to use as the base when building the application.

buildImage = ''


Key-value pairs of variables to include in the final image.

NODE_ENV = 'production'
HELLO = 'world'

Static assets#

Files that are copied into the /assets directory of the image.

myFile = '''


The phases specify exactly how the application is built and packaged into an image. Each phase can depend on a list of other phases and the ordering is resolved when the Dockerfile is automatically generated and run. The phases are typically defined as

  • setup: Install the Nix/Apt packages (e.g. NodeJS, Yarn)
  • install: Install the language/framework dependencies (e.g. Yarn install)
  • build: Build the application (e.g. Yarn build)

However, there is no restriction on the names of phases or what they are named.

# ...

# ...

# ...


Array of commands to run.

  cmds = ['cmd1', 'cmd2']

Nix packages#

Nix packages to install. Available packages can be found at

  nixPkgs = ['cowsay']

Nix libraries#

Nix packages to be made available through the LD_LIBRARY_PATH environment variables. The paths to each packages library files are appended.

  nixLibs = ['zlib']

Nix overlays#

Nix overlays to use as alternate package sources.

  nixOverlays = ['']

Nixpkgs archive#

Specific version of the Nixpkgs archive to use. By default all builds are built using the version defined here. But this value can be overridden to install Nix packages from an older archive.

  nixpkgsArchive = '21de2b973f9fee595a7a1ac4693efff791245c34'

Apt packages#

List of packages to install with apt-get

  aptPkgs = ['wget']

Phase dependencies#

List of phases that this phase must run after.

  dependsOn = ['install']

Cache directories#

Directories to cache for this phase. Cached directories do not appear in the final build. See /caching for more information.

  cacheDirectories = ['node_modules/.cache']

Included files#

Files to only make available when running this phase. If no array is specified, then all files are copied into the image before running the commands. This can be useful when optimizing the Docker layer cache.

  onlyIncludeFiles = ['package.json']

Note: Files included from previous phases will also be available.


Paths to append to the PATH environment variable.

  paths = ['/app/node_modules/.bin']

Start Phase#

This configures how a container created from the image will start.


The command to run when starting the container.

  cmd = "yarn run start"

Run image#

The runtime image to use. If not specified, the same build image will be used.

  runImage = 'debian:bullseye-slim'

Included files#

Must be used in combination with runImage. The only files that should be copied over to the run image. If no value is specified, the entire app directory is copied over.

  onlyIncludeFiles = ['./bin/rust-custom-version']