Skip to main content

Build with Flox

Not only can you develop your software with Flox, but you can build it as well. See the builds concept page for more details.

Manifest builds

npm

Building Node.js packages with npm looks similar to building for containers or serverless functions. On a high level, builds for Node.js-based projects generally follow this pattern:
If you expect to install multiple Node.js applications in the same environment, we recommend putting the dist (and optional node_modules) under an appropriate namespace, e.g. create /libexec/myproject/dist in your build. For the run script, if your npm build already produces a binary that can be executed directly, you can also copy or link that to $out/bin. Note that only binaries in $out/bin are wrapped to ensure they run within a consistent environment.

Vendoring dependencies in pure builds

As discussed in the pure builds of the Builds concept page, pure builds run in a sandbox without network access on Linux. A pure build can be run as a multi-stage build where the first step vendors dependencies. An example is shown below:

Nix expression builds

To build a project using buildNpmPackage which will import your existing dependency file: