Skip to main content

Overview

Catalog imports allow your Nix expression builds to depend on packages provided by external sources: FloxHub users and organizations that publish reusable packages, or remote repositories containing Nix expression definitions. Nix expression builds already support vendoring existing packages by copying their expressions into your .flox/pkgs/ directory. Catalog imports extend this model by allowing expression sharing through a central registry at the granularity of catalogs, which correspond to FloxHub user or organization namespaces, or to external repositories. You declare catalogs in a configuration file and access their packages via the catalogs argument in your expressions; this keeps your build inputs explicit, lockable, and reproducible. Catalog imports are a feature of Nix expression builds specifically; they do not apply to manifest-based builds. You should be familiar with defining packages in .flox/pkgs/ before using catalog imports.

Configuring catalogs

Catalog imports use two files:
  • .flox/nix-builds.toml, the user-authored configuration file where you declare which catalogs to use.
  • .flox/nix-builds.lock, a generated lockfile that pins each catalog to a specific revision for reproducibility.
Both files must be tracked by Git (git added) and should be committed to version control. The TOML file is authored by hand; the lockfile is generated and updated by the flox build update-catalogs command.

Catalog types

FloxHub catalogs

A FloxHub catalog references packages published to FloxHub via flox publish. The catalog name corresponds to the FloxHub user or organization that published them.
.flox/nix-builds.toml
Or with dotted key syntax:
.flox/nix-builds.toml
Your own catalog is always accessible after authenticating with flox auth login. Organization catalogs are accessible to all members of the organization. Cross-user catalog sharing is not yet available on public FloxHub; for now, catalog imports between users require Flox on-prem.

Nix source-ref catalogs

A source-ref catalog points at any Nix source reference: a Git repository, tarball, or other supported source type. The most common case is a Git repository that contains Flox package definitions (a .flox/pkgs/ directory). You can declare a source-ref catalog in structured form, specifying the type and additional fields:
.flox/nix-builds.toml
As a shorthand, you can provide a single url field using Nix source reference syntax (the git+ prefix encodes the type):
.flox/nix-builds.toml
You can also use TOML dotted key syntax under a [catalogs] header for simple cases:
.flox/nix-builds.toml
The supported source types and their fields are documented in the Nix manual.

Common fields for git sources

Other source types (github, gitlab, tarball, etc.) accept their own fields; for example, github and gitlab support a host field for self-hosted instances. See the Nix source types reference for the full list. These fields are written as separate TOML keys when using the structured form (type + url). When using the URL shorthand, encode them as query parameters instead:
.flox/nix-builds.toml
For example, to point at a subdirectory within a monorepo using the structured form:
.flox/nix-builds.toml

Using catalogs in expressions

Once catalogs are declared in .flox/nix-builds.toml and the lockfile is generated, you access imported packages through the catalogs argument in your Nix expressions.
The argument name must be catalogs (plural). Using catalog (singular) will not work.
Access packages by catalog name and package name:
For example, an expression that uses a package from a catalog:
.flox/pkgs/demo.nix
The catalogs argument can be combined with other arguments from nixpkgs:
.flox/pkgs/my-app.nix

Updating catalog locks

Before you can build with catalog imports, you must generate the lockfile. Run:
This resolves each catalog declaration in .flox/nix-builds.toml and writes the pinned revisions to .flox/nix-builds.lock. Re-run this command whenever you:
  • Add or change a catalog entry in .flox/nix-builds.toml
  • Want to pick up newer versions of packages from a catalog
After updating, git add and commit both .flox/nix-builds.toml and .flox/nix-builds.lock.
If you run flox build without a lockfile, you will see:
If the lockfile exists but is stale (you added or changed a catalog in .flox/nix-builds.toml without re-running flox build update-catalogs), the error will be:
In either case, run flox build update-catalogs to resolve catalog entries and regenerate the lockfile.

Examples

Example: FloxHub catalog

This example uses a package published to FloxHub by the organization my-org. 1. Declare the catalog:
.flox/nix-builds.toml
2. Write an expression that uses it:
.flox/pkgs/demo.nix
3. Update the lockfile and build:

Example: Git catalog

This example imports a Rust application from the flox-build-examples repository. 1. Declare the catalog:
.flox/nix-builds.toml
2. Write an expression that uses it:
.flox/pkgs/demo.nix
3. Update the lockfile and build:

Example: Combining catalogs with nixpkgs

A realistic expression might use both catalog imports and standard nixpkgs helpers:
.flox/pkgs/my-tool.nix
Here rustPlatform and lib come from nixpkgs, as with any standard Nix expression build. The catalogs.shared-libs.crypto-utils dependency is resolved from the declared catalog.