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 may see packages that won't immediately work with your manifest, but finding and allowing system specific packages is very easy.
Flox shows software from the following systems: aarch64-darwin
, x86_64-darwin
, aarch64-linux
, and x86_64-linux
.
Some packages may support only a subset of system types. You can inspect a
package with flox show
to see what system types are supported:
$ flox show gdb
gdb - The GNU Project debugger
[email protected] (aarch64-linux, x86_64-darwin, x86_64-linux only)
[email protected] (aarch64-linux, x86_64-darwin, x86_64-linux only)
[email protected] (aarch64-linux, x86_64-darwin, x86_64-linux only)
[email protected] (aarch64-linux, x86_64-darwin, x86_64-linux only)
...
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
.
Then lets run the a simple gpg --version
command to test everything is working.
$ flox pull youruser/eng-team-tools
✨ Pulled youruser/eng-team-tools from https://hub.flox.dev
You can activate this environment with 'flox activate'
$ flox activate -- gpg --version
gpg (GnuPG) 2.4.5
libgcrypt 1.10.3
Copyright (C) 2024 g10 Code GmbH
...
Looks like the environment works cross-platform, nice!
Handling unsupported packages
However, some packages only work with a subset of systems. To demonstrate this let's install a package that isn't compatible with an Apple machine and set a system-specific option for these packages.
From the Linux machine...
$ flox install systemd # (1)!
❌ ERROR: resolution failed: package 'systemd' not available for
- aarch64-darwin
- x86_64-darwin
but it is available for
- aarch64-linux
- x86_64-linux
systemd
is only available on Linux systems
To install systemd
for compatible systems, flox edit
the manifest.
We will add systemd and include its systems
attribute to filter only for
the supported systems.
[install]
...
gnupg.pkg-path = "gnupg" # (1)!
vim.pkg-path = "vim"
systemd.pkg-path = "systemd" # (2)!
systemd.systems = ["aarch64-linux", "x86_64-linux"] # (3)!
- These packages were installed using
flox install
earlier. - Here we are declaring a new installation,
systemd
. - To allow non-Linux users to use this environment, the system attribute filters for just Linux systems.
With the edits complete, save and quit your editor. The environment should update successfully!
Finally, we can push this update so we can list packages from the Apple machine to verify everything works.
$ 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.
Then, from the Apple machine, lets pull the latest.
$ flox pull
✅ Pulled ghudgins/default from https://hub.flox.dev/
You can activate this environment with 'flox activate'
$ flox list
gnupg: gnupg (2.4.5)
vim: vim (9.1.0377)
$ flox list -c
...
[install]
gnupg.pkg-path = "gnupg"
vim.pkg-path = "vim"
systemd.pkg-path = "systemd"
systemd.systems = ["aarch64-linux"]
...
The Apple machine does not have systemd
despite it appearing in the manifest.
This environment will activate on both machines and the Apple machine won't
get the systemd
package.