Skip to content

Commit f4b2221

Browse files
committed
docs: align pixi module docs with upstream style
1 parent f10d3db commit f4b2221

8 files changed

Lines changed: 298 additions & 161 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ colliding with the upstream project name.
1717

1818
| Module | Description |
1919
|--------|-------------|
20-
| [`pixi`](./pixi) | Tooling for [Pixi](https://pixi.prefix.dev/latest/)-managed Python projects: verify checked-in `pixi.lock` files, install one or many environments in the same [Dagger](https://dagger.io) container, build filtered runtime images without Pixi, and run commands through Pixi. |
20+
| [`pixi`](./pixi) | Tooling for [Pixi](https://pixi.prefix.dev/latest/)-managed Python projects: install one or many environments in the same [Dagger](https://dagger.io) container, build filtered runtime images without Pixi, and run commands through Pixi. |

pixi/docs/building.md

Lines changed: 112 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,116 @@
11
---
2-
icon: lucide/terminal
2+
icon: lucide/package
33
title: Building containers
4-
description: Install and run Pixi environments inside Dagger containers.
4+
description: Install Pixi environments in Dagger containers and build runtime images without shipping Pixi itself.
55
---
66

7-
# Building Containers
7+
# Building containers
88

9-
`install` copies the source tree into a Pixi image, mounts Pixi caches, and runs
10-
`pixi install --locked` for a named environment inside a
11-
[Dagger](https://dagger.io) container. The returned container is a builder-style
12-
container and includes the Pixi binary.
9+
This is the module's core feature: turning a [Pixi](https://pixi.prefix.dev/latest/)
10+
workspace into a [Dagger](https://dagger.io) container with one or more named
11+
environments installed.
1312

14-
```python
15-
from dagger import dag
13+
Pixi remains responsible for solving, locking, and installing. The module provides
14+
the Dagger shape around it: source mounting, cache volumes, environment selection,
15+
Dagger SDK codegen overlays, and runtime images that keep the installed
16+
`.pixi/envs/*` directories but leave the Pixi binary behind.
1617

17-
ctr = await dag.pixi(source=src).install(environment="default")
18-
```
18+
??? abstract "The mental model"
1919

20-
Install more than one environment into the same container:
20+
```mermaid
21+
graph LR
22+
P["Pixi<br/><i>source tree</i>"] -->|workspace / get_workspaces| WS["PixiWorkspaceSource<br/><i>one per pixi.lock</i>"]
23+
P -->|install / run / runtime| Root["Default workspace<br/><i>path = .</i>"]
24+
WS -->|install_environments| Builder["Builder container<br/><i>Pixi image</i>"]
25+
Builder -->|runtime_environments| Runtime["Runtime container<br/><i>no Pixi binary</i>"]
26+
```
2127

22-
```python
23-
ctr = await dag.pixi(source=src).install_environments(environments=["default", "docs"])
24-
```
28+
- **`Pixi`** holds your source tree. Its root functions use the workspace at `.`
29+
and accept `path` when your Pixi workspace lives deeper in the tree.
30+
- **`PixiWorkspaceSource`** is one Pixi workspace rooted at a `pixi.lock`. It is
31+
useful when you want to keep a workspace object around explicitly.
32+
- **Builder containers** use a Pixi image and can run `pixi install` / `pixi run`.
33+
- **Runtime containers** copy selected `.pixi/envs/*` directories and an
34+
entrypoint into a fresh image.
2535

26-
Use `run` for one-off commands:
36+
## `install` - the one-call path
2737

28-
```python
29-
ctr = await dag.pixi(source=src).run(args=["python", "--version"])
30-
```
38+
`install` returns a builder-style container with one Pixi environment installed.
3139

32-
Use `runtime` for a deployable image without Pixi. It installs with Pixi in a
33-
builder, copies the selected `.pixi/envs/*` directories and a Bash entrypoint
34-
into a runtime image, and leaves the Pixi binary behind.
40+
=== "CLI"
3541

36-
```python
37-
runtime = await dag.pixi(source=src).runtime(environment="default")
38-
```
42+
```console
43+
$ dagger call pixi install --environment default
44+
```
3945

40-
For a final image with several Pixi environments:
46+
=== "Python SDK"
4147

42-
```python
43-
runtime = await dag.pixi(source=src).runtime_environments(
44-
environments=["default", "model-downloader"],
45-
entrypoint_environment="default",
46-
)
47-
```
48+
```python
49+
from dagger import dag
50+
51+
ctr = await dag.pixi(source=src).install(environment="default")
52+
```
53+
54+
Use `run` for a one-off command in that environment:
55+
56+
=== "CLI"
57+
58+
```console
59+
$ dagger call pixi run --args python --args --version
60+
```
61+
62+
=== "Python SDK"
63+
64+
```python
65+
ctr = await dag.pixi(source=src).run(args=["python", "--version"])
66+
```
67+
68+
## Multiple environments
69+
70+
`install_environments` installs several Pixi environments into the same builder
71+
container.
72+
73+
=== "CLI"
74+
75+
```console
76+
$ dagger call pixi install-environments \
77+
--environments default \
78+
--environments docs
79+
```
80+
81+
=== "Python SDK"
82+
83+
```python
84+
ctr = await dag.pixi(source=src).install_environments(
85+
environments=["default", "docs"],
86+
)
87+
```
88+
89+
To install every declared environment, use `install_all_environments`.
90+
91+
## Runtime images
92+
93+
Use `runtime` or `runtime_environments` for deployable images. The module installs
94+
with Pixi in a builder, copies the selected `.pixi/envs/*` directories and a Bash
95+
entrypoint into a runtime image, and leaves the Pixi binary behind.
96+
97+
=== "CLI"
98+
99+
```console
100+
$ dagger call pixi runtime-environments \
101+
--environments default \
102+
--environments model-downloader \
103+
--entrypoint-environment default
104+
```
105+
106+
=== "Python SDK"
107+
108+
```python
109+
runtime = await dag.pixi(source=src).runtime_environments(
110+
environments=["default", "model-downloader"],
111+
entrypoint_environment="default",
112+
)
113+
```
48114

49115
For a tighter runtime image, copy only the source paths that target needs:
50116

@@ -63,22 +129,22 @@ runtime = await dag.pixi(source=src).runtime_environments(
63129
)
64130
```
65131

66-
Use `path` when the Pixi workspace is not at the source root:
132+
`runtime_source_paths` is source-root-relative and accepts paths or glob patterns.
133+
For a nested Pixi workspace, include the workspace prefix when needed.
67134

68-
```python
69-
ctr = await dag.pixi(source=src).install_environments(
70-
path="services/api",
71-
environments=["default", "docs"],
72-
)
73-
```
135+
## Choosing images
74136

75-
Pixi features become concrete through environments. For example, an environment
76-
declared with `features = ["docs"]` is installed by passing the environment name,
77-
not the feature name.
137+
The default builder image is `ghcr.io/prefix-dev/pixi:0.70.2`, or the concrete
138+
version resolved from `requires-pixi` when the workspace declares one. Pass
139+
`pixi_version` or `image` to override it.
78140

79141
The default runtime image is `ubuntu:noble`. Pass `runtime_image` or
80-
`runtime_base_container` to add operating-system packages before the Pixi
81-
environments are copied in.
142+
`runtime_base_container` when the final image needs operating-system packages,
143+
users, certificates, or another base.
144+
145+
## Dagger modules as dependencies
82146

83-
The default image is `ghcr.io/prefix-dev/pixi:0.70.2`. Pass `image` or
84-
`pixi_version` to override the builder image.
147+
If the workspace is itself a Dagger module, the module runs Dagger codegen and
148+
overlays the generated SDK before installing, so the generated `dagger-io` package
149+
is present even when `sdk/` is gitignored in CI. This is on by default and is a
150+
no-op for non-Dagger projects.

pixi/docs/checks/locked.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

pixi/docs/environments.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
icon: lucide/box
3+
title: Environments and features
4+
description: Use Pixi features to define environments, then install those environments in Dagger containers.
5+
---
6+
7+
# Environments and features
8+
9+
Pixi features are reusable chunks of project configuration. They can add
10+
dependencies, PyPI dependencies, tasks, channels, platforms, activation scripts,
11+
and system requirements. Pixi environments are the named, installable combinations
12+
of those features.
13+
14+
This module works at the environment level because that is what Pixi installs and
15+
runs. Define features in `pyproject.toml` or `pixi.toml`, compose them into
16+
environments, then pass those environment names to Dagger.
17+
18+
## Define environments
19+
20+
```toml
21+
[tool.pixi.dependencies]
22+
python = ">=3.13,<3.15"
23+
24+
[tool.pixi.feature.docs.dependencies]
25+
mkdocs = ">=1.6,<2"
26+
27+
[tool.pixi.feature.model.dependencies]
28+
pytorch = ">=2.5,<3"
29+
30+
[tool.pixi.environments]
31+
default = { solve-group = "default" }
32+
docs = { features = ["docs"], no-default-feature = true }
33+
model = { features = ["model"] }
34+
```
35+
36+
In this example:
37+
38+
- `default` installs the base dependencies.
39+
- `docs` installs only the `docs` feature because `no-default-feature = true`.
40+
- `model` installs base dependencies plus the `model` feature.
41+
42+
## List environments
43+
44+
=== "CLI"
45+
46+
```console
47+
$ dagger call pixi environments
48+
```
49+
50+
=== "Python SDK"
51+
52+
```python
53+
names = await dag.pixi(source=src).environments()
54+
```
55+
56+
For a nested workspace, pass `path`:
57+
58+
```console
59+
$ dagger call pixi environments --path services/api
60+
```
61+
62+
## Install several environments
63+
64+
Several environments can live in the same returned container:
65+
66+
=== "CLI"
67+
68+
```console
69+
$ dagger call pixi install-environments \
70+
--environments default \
71+
--environments docs \
72+
--environments model
73+
```
74+
75+
=== "Python SDK"
76+
77+
```python
78+
ctr = await dag.pixi(source=src).install_environments(
79+
environments=["default", "docs", "model"],
80+
)
81+
```
82+
83+
Use `install_all_environments` when the container should include every environment
84+
declared by the workspace.
85+
86+
## Choose the entrypoint environment
87+
88+
A runtime image may carry several Pixi environments, but its entrypoint activates
89+
one of them.
90+
91+
```python
92+
runtime = await dag.pixi(source=src).runtime_environments(
93+
environments=["default", "docs", "model"],
94+
entrypoint_environment="model",
95+
)
96+
```
97+
98+
That image contains `.pixi/envs/default`, `.pixi/envs/docs`, and
99+
`.pixi/envs/model`. The entrypoint activates `.pixi/envs/model`.
100+
101+
## Features are not installed directly
102+
103+
Do not pass feature names to the module unless an environment has the same name.
104+
Pixi may define a feature called `docs`, but the install target is the environment
105+
declared under `[tool.pixi.environments]` or `[environments]`.
106+
107+
```toml
108+
[tool.pixi.feature.docs.dependencies]
109+
mkdocs = ">=1.6,<2"
110+
111+
[tool.pixi.environments]
112+
documentation = { features = ["docs"], no-default-feature = true }
113+
```
114+
115+
Install `documentation`, not `docs`:
116+
117+
```console
118+
$ dagger call pixi install --environment documentation
119+
```
120+
121+
See Pixi's own documentation for the full environment and feature grammar:
122+
[Pixi environments](https://pixi.prefix.dev/latest/workspace/environment/) and
123+
[multi-environment workspaces](https://pixi.prefix.dev/latest/workspace/multi_environment/).

0 commit comments

Comments
 (0)