Skip to content

Commit 0a70aca

Browse files
committed
feat: add floxhub environments page
1 parent 8ea1c31 commit 0a70aca

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

.flox/env/manifest.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,4 +1409,4 @@
14091409
"priority": 5
14101410
}
14111411
]
1412-
}
1412+
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
title: "FloxHub environments"
3+
description: "Reusable environments that are centrally managed on FloxHub"
4+
---
5+
6+
When you create an environment for your project, you often do so via the [`flox init`][flox-init] command, which creates a `.flox` directory that you can check into source control.
7+
8+
```{ .sh .copy}
9+
flox init
10+
git add .flox
11+
```
12+
13+
This allows you to track changes to the environment the same way that you track changes to your source code, but it also ties this environment to this specific project and Git repository.
14+
15+
Another way of working is to [push][flox-push] an environment to [FloxHub][floxhub] to turn it into a reusable, centrally managed environment.
16+
17+
```{ .sh }
18+
$ flox push
19+
✅ Updates to myenv successfully pushed to FloxHub
20+
21+
View the environment at: https://hub.flox.dev/myuser/myenv
22+
Use this environment from another machine: 'flox activate -r myuser/myenv'
23+
Make a copy of this environment: 'flox pull myuser/myenv'
24+
```
25+
26+
Once pushed, the state and history of this environment are tracked on FloxHub in the form of [generations][generations].
27+
Let's explore how FloxHub environments work and the kinds of workflows they enable.
28+
29+
[flox-init]: ../man/flox-init.md
30+
[flox-push]: ../man/flox-push.md
31+
[floxhub]: ./floxhub.md
32+
[generations]: ./generations.md
33+
34+
## Terminology
35+
36+
We call an environment that has been pushed to FloxHub a **"FloxHub environment"**.
37+
One of the primary benefits of FloxHub environments is that they can be reused in different contexts, by different people, on different machines.
38+
39+
This means you frequently have multiple copies of the environment:
40+
41+
- The copy that lives on FloxHub, which is the source of truth
42+
- The copy that exists locally for a given user on a given machine
43+
44+
We call the copy of the environment on FloxHub the **"upstream"** copy, and the copy on a user's machine the **"local"** copy.
45+
46+
## Getting a FloxHub environment
47+
48+
Once you've pushed an environment to FloxHub, you can then use the [`flox pull`][flox-pull] command to fetch a copy of the environment to your machine.
49+
50+
A FloxHub environment can exist on your machine in two different forms:
51+
52+
- A cached copy transparently managed by Flox
53+
- Fetch this manually via `flox pull --reference <owner>/<name>`
54+
- Materialized into a user-specified directory
55+
- Created via `flox pull <owner>/<name>`
56+
- Placed into the current directory by default
57+
- Specify a different directory with the `-d/--directory` flag
58+
59+
This cached copy is created and managed by the Flox CLI.
60+
Additionally, the Flox CLI will automatically fetch updates from FloxHub (without automatically applying them) so that the locally cached copy of the environment has up to date knowledge of the upstream state.
61+
62+
The upstream state of the environment can be fetched manually via the `flox pull (-r | --reference) <owner>/<name>` command.
63+
64+
## Operations on FloxHub environments
65+
66+
CLI commands that interact with FloxHub environments will primarily operate on the cached copy of the environment.
67+
This allows you to use FloxHub environments offline if a cached copy exists.
68+
69+
As an example, installing a package via [`flox install -r`][flox-install] will operate on the local copy, creating a new [generation][generations] of the local copy.
70+
The Flox CLI indicates when an operation has been performed on the local copy (note the `(local)` text in the example below).
71+
72+
```
73+
$ flox install -r myuser/myenv ripgrep
74+
✅ 'ripgrep' installed to environment 'myuser/myenv' (local)
75+
```
76+
77+
When the Flox CLI detects that the local and upstream copies are out of sync (for example, you have a new local generation corresponding to the new package you installed), it will notify you with instructions on how to proceed.
78+
For the example above, you would see the following output when activating the environment:
79+
80+
```
81+
$ flox activate -r myuser/myenv
82+
ℹ️ Environment out of sync with FloxHub.
83+
84+
Local:
85+
86+
* myuser installed package 'ripgrep (ripgrep)' on mymachine
87+
Generation: 2
88+
Timestamp: 2025-12-15 21:04:27 UTC
89+
90+
Remote:
91+
92+
* myuser imported environment on mymachine
93+
Generation: 1
94+
Timestamp: 2025-12-15 18:57:23 UTC
95+
96+
Use 'flox push|pull -r myuser/myenv' to fetch updates or update the environment on FloxHub.
97+
98+
✅ You are now using the environment 'myuser/myenv (local)'.
99+
To stop using this environment, type 'exit'
100+
```
101+
102+
The `flox activate` command succeeds, but the message indicates that you need to run either a `flox pull` or `flox push` command (`flox push` in this case since you have local changes):
103+
104+
```
105+
Use 'flox push|pull -r myuser/myenv' to fetch updates or update the environment on FloxHub.
106+
```
107+
108+
Running the `flox push` command syncs local changes to the upstream copy on FloxHub:
109+
110+
```
111+
$ flox push -r myuser/myenv
112+
✅ Updates to myenv successfully pushed to FloxHub
113+
114+
View the environment at: https://hub.flox.dev/myuser/myenv
115+
Use this environment from another machine: 'flox activate -r myuser/myenv'
116+
Make a copy of this environment: 'flox pull myuser/myenv'
117+
```
118+
119+
[flox-pull]: ../man/flox-pull.md
120+
[flox-install]: ../man/flox-install.md
121+
122+
## Getting information from upstream
123+
124+
### Generations
125+
126+
Both the local and upstream FloxHub environments track their state over time via generations.
127+
For an in-depth explanation of generations, see the [Generations][generations] concept page.
128+
129+
In order to view the list of generations as understood by the local copy, you use the [`flox generations list`][gen-list] command.
130+
To see the list of generations as understood by the upstream copy, you add the `--upstream` flag.
131+
132+
In order to view the _history_ of generations (which displays how the "live" generation has evolved over time, any rollbacks that occurred, etc), you use [`flox generations history`][gen-hist].
133+
Again, the `--upstream` flag will show you the history as understood by the upstream copy.
134+
135+
### Packages
136+
137+
In order to see the list of packages in the local copy of a FloxHub environment you use the [`flox list -r`][flox-list] command.
138+
Add the `--upstream` flag to see the packages in the upstream copy of the FloxHub environment.
139+
140+
[gen-list]: ../man/flox-generations-list.md
141+
[gen-hist]: ../man/flox-generations-history.md
142+
[flox-list]: ../man/flox-list.md
143+
144+
## Activating a FloxHub environment
145+
146+
Activating a FloxHub environment is done via the [`flox activate -r`][flox-activate] command.
147+
This will activate the current state of the local copy of the FloxHub environment, which may not be up to date with the upstream copy.
148+
To activate the environment as it exists upstream, run `flox pull -r <owner>/<name>` before running `flox activate`.
149+
150+
[flox-activate]: ../man/flox-activate.md

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ nav:
6767
- Environments: concepts/environments.md
6868
- Activating environments: concepts/activation.md
6969
- FloxHub: concepts/floxhub.md
70+
- FloxHub environments: concepts/floxhub-environments.md
7071
- Generations: concepts/generations.md
7172
- Catalog and Packages: concepts/packages-and-catalog.md
7273
- Base Catalog: concepts/base-catalog.md

0 commit comments

Comments
 (0)