Skip to content

Designing multiple architecture environments

Flox makes it simple to have the same environment on multiple systems and CPU architectures. This guide walks through an example between two coworkers who have different system types, and shows how to customize your environment with system-specific dependencies.

Creating an environment

To get started, let's create an environment from a Linux laptop. This laptop is using an ARM CPU (aarch64) which makes its full system type aarch64-linux.

When using flox search you will, by default, only get packages that match the current system type.

First let's install some packages to our environment running on Linux:

$ flox init --name eng-team-tools
✨ Created environment eng-team-tools (aarch64-linux)
...
$ flox install gnupg vim
✅ 'gnupg' installed to environment eng-team-tools at /home/youruser
✅ 'vim' installed to environment eng-team-tools at /home/youruser

To make it easy to share this system across platforms we are going to share it on FloxHub with flox push.

$ flox push
✅  eng-team-tools successfully pushed to FloxHub

    Use 'flox pull youruser/eng-team-tools' to get this environment in any other location.

Learn more about this and other sharing options in the sharing environments guide.

Using the environment from a different system type

Many packages in Flox will work without any issue across system types.

To test this out, run flox pull from another system such as an Apple machine with an M-series processor (this system type is aarch64-darwin).

$ flox pull youruser/eng-team-tools
! The environment you are trying to pull is not yet compatible with your system (aarch64-darwin).
  Don't pull this environment.
> Pull this environment anyway and add 'aarch64-darwin' to the supported systems list.
[Use 'flox pull --add-system' to automatically add your system to the list of compatible systems]

You'll notice a choice at this step. Let's add support for Apple M processors by picking the Pull this environment anyway option in the interactive prompt.

This option will append the new system to the environment's manifest.toml (accessible with flox edit) and build the environment for the current system.

✨  Pulled youruser/eng-team-tools from https://hub.flox.dev

    You can activate this environment with 'flox activate'

Now that we know this environment works on this system, we can share it with others by running another flox push.

$ flox push
✅  Updates to eng-team-tools successfully pushed to FloxHub

    Use 'flox pull youruser/eng-team-tools' to get this environment in any other location.

Handling unsupported packages

Back on the Linux machine, let's install a package that isn't compatible with an Apple machine to see how to update the environment to handle system-specific packages.

$ flox install gdb
✅ 'gdb' installed to environment youruser/eng-team-tools at /home/youruser

Let's push this update so we can try from the Apple machine.

$ flox push
✅  Updates to eng-team-tools successfully pushed to FloxHub

    Use 'flox pull youruser/eng-team-tools' to get this environment in any other location.

From the Apple machine, try pulling the environment again:

$ flox  youruser/eng-team-tools

! The environment you are trying to pull is not yet compatible with your system (aarch64-darwin).
  Don't pull this environment.
> Pull this environment anyway and add 'aarch64-darwin' to the supported systems list.
...

You will see a prompt that allows you to pull the environment by adding your system. Pull this environment anyway to get a copy.

gdb is not compatible with MacOS so you will see an additional error. To address this, we will scope gdb to just the Linux system type in the environment manifest with flox edit.

$ flox edit

In the install section, we can add a list of systems for any installed package and make the package optional:

manifest.toml
[install]
...
gdb.pkg-path = "gdb"
gdb.systems = ["aarch64-linux"] # (1)
gdb.optional = true # (2)
  1. Supported systems for this package
  2. Indicates if this package is optional

Save and exit your editor, and you should see the environment is now valid! You can safely flox push the environment that now works across multiple architecture even with a system-specific package being used.

$ flox edit
✅ Environment successfully updated.
$ flox push 
✅  Updates to eng-team-tools successfully pushed to FloxHub

    Use 'flox pull youruser/eng-team-tools' to get this environment in any other location.

Where to next?