You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Summary
Add docs for the new schema and commands that support platform specific
packages
## How was it tested?
Localhost, also check Vercel Docs for more details
Copy file name to clipboardExpand all lines: docs/app/docs/configuration.md
+84-3Lines changed: 84 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Your devbox configuration is stored in a `devbox.json` file, located in your pro
7
7
8
8
```json
9
9
{
10
-
"packages": [],
10
+
"packages": []| {},
11
11
"env": {},
12
12
"shell": {
13
13
"init_hook": "...",
@@ -22,9 +22,56 @@ Your devbox configuration is stored in a `devbox.json` file, located in your pro
22
22
23
23
### Packages
24
24
25
-
This is a list of Nix packages that should be installed in your Devbox shell and containers. These packages will only be installed and available within your shell, and will have precedence over any packages installed in your local machine. You can search for Nix packages using [Nix Package Search](https://search.nixos.org/packages).
25
+
This is a list or map of Nix packages that should be installed in your Devbox shell and containers. These packages will only be installed and available within your shell, and will have precedence over any packages installed in your local machine. You can search for Nix packages using [Nix Package Search](https://search.nixos.org/packages).
26
26
27
-
You can add packages to your devbox.json using `devbox add <package_name>`, and remove them using `devbox rm <package_name>`
27
+
You can add packages to your devbox.json using `devbox add <package_name>`, and remove them using `devbox rm <package_name>`.
28
+
29
+
Packages can be structured as a list of package names (`<packages>@<version>`) or [flake references](#adding-packages-from-flakes):
30
+
31
+
```json
32
+
{
33
+
"packages": [
34
+
"go@latest"
35
+
"golangci-lint@latest"
36
+
]
37
+
}
38
+
```
39
+
40
+
If you need to provide more options to your packages (such as limiting which platforms will install the package), you can structure packages as a map, where each package follows the schema below:
41
+
42
+
```json
43
+
{
44
+
"packages": {
45
+
// If only a version is specified, you can abbreviate the maps as "package_name": "version"
46
+
"package_name": string,
47
+
"package_name": {
48
+
// Version of the package to install. Defaults to "latest"
49
+
"version": string,
50
+
// List of platforms to install the package on. Defaults to all platforms
51
+
"platforms": [string],
52
+
// List of platforms to exclude this package from. Defaults to no excluded platforms
53
+
"excluded_platforms": [string]
54
+
}
55
+
}
56
+
}
57
+
```
58
+
59
+
For example:
60
+
61
+
```json
62
+
{
63
+
"packages": {
64
+
"go" : "latest",
65
+
"golangci-lint": "latest",
66
+
"glibcLocales": {
67
+
"version": "latest",
68
+
"platforms": ["x86_64-linux, aarch64-linux"]
69
+
}
70
+
}
71
+
}
72
+
```
73
+
74
+
Note that `devbox add` will automatically format `packages` based on the options and packages that you provide.
28
75
29
76
#### Pinning a Specific Version of a Package
30
77
@@ -65,6 +112,40 @@ You can add packages from flakes by adding a reference to the flake in the `pac
65
112
66
113
To learn more about using flakes, see the [Using Flakes](guides/using_flakes.md) guide.
67
114
115
+
#### Adding Platform Specific Packages
116
+
117
+
You can choose to include or exclude your packages on specific platforms by adding a `platforms` or `excluded_platforms` field to your package definition. This is useful if you need to install packages or libraries that are only available on specific platforms (such as `busybox` on Linux, or `utm` on macOS):
At times, you may need to install a package or library that is only available on a specific platform. For example, you may want to install a package that is only available on Linux, while still using the same Devbox configuration on your Mac.
6
+
7
+
Devbox allows you to specify which platforms a package should be installed on using the `--platform` and `--exclude-platform` flags. When a package is added using these flags, it will be added to your `devbox.json`, but will only be installed when you run Devbox on a matching platform.
8
+
9
+
:::info
10
+
11
+
Specifying platforms for packages will alter your `devbox.json` in a way that is only compatible with **Devbox 0.5.12** and newer.
12
+
13
+
If you encounter errors trying to run a Devbox project with platform-specific packages, you may need to run `devbox version update`
14
+
:::
15
+
16
+
## Installing Platform Specific Packages
17
+
18
+
To avoid build or installation errors, you can tell Devbox to only install a package on specific platforms using the `--platform` flag when you run `devbox add`.
19
+
20
+
For example, to install the `busybox` package only on Linux platforms, you can run:
This will add busybox to your `devbox.json`, but will only install it when use devbox on a Linux machine. The packages section in your config will look like the following
27
+
28
+
```json
29
+
{
30
+
"packages": {
31
+
"busybox": {
32
+
"version": "latest",
33
+
"platforms": ["x86_64-linux", "aarch64-linux"]
34
+
}
35
+
}
36
+
}
37
+
```
38
+
39
+
## Excluding a Package from Specific Platforms
40
+
41
+
You can also tell Devbox to exclude a package from a specific platform using the `--exclude-platform` flag. For example, to avoid installing `ripgrep` on an ARM-based Mac, you can run:
This will add ripgrep to your `devbox.json`, but will not install it when use devbox on an ARM-based Mac. The packages section in your config will look like the following:
49
+
50
+
```json
51
+
{
52
+
"packages": {
53
+
"ripgrep": {
54
+
"version": "latest",
55
+
"excluded_platforms": ["aarch64-darwin"]
56
+
}
57
+
}
58
+
}
59
+
```
60
+
61
+
## Supported Platforms
62
+
63
+
Valid Platforms include:
64
+
65
+
*`aarch64-darwin`
66
+
*`aarch64-linux`
67
+
*`x86_64-darwin`
68
+
*`x86_64-linux`
69
+
70
+
The platforms below are also supported, but will build packages from source
0 commit comments