Skip to content

Commit cec782c

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/docs/app/elliptic-6.6.0
Signed-off-by: John Lago <[email protected]>
2 parents d389587 + d7b68b1 commit cec782c

File tree

154 files changed

+2619
-5987
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+2619
-5987
lines changed

.schema/devbox.schema.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,16 @@
139139
},
140140
"env_from": {
141141
"type": "string"
142+
},
143+
"nixpkgs": {
144+
"type": "object",
145+
"properties": {
146+
"commit": {
147+
"type": "string",
148+
"description": "The commit hash of the nixpkgs repository to use"
149+
}
150+
}
142151
}
143152
},
144153
"additionalProperties": false
145-
}
154+
}

devbox.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Package devbox creates and configures Devbox development environments.
2+
package devbox
3+
4+
import (
5+
"context"
6+
"io"
7+
8+
"go.jetpack.io/devbox/internal/devbox"
9+
"go.jetpack.io/devbox/internal/devbox/devopt"
10+
)
11+
12+
// Devbox is a Devbox development environment.
13+
type Devbox struct {
14+
dx *devbox.Devbox
15+
}
16+
17+
// Open loads a Devbox environment from a config file or directory.
18+
func Open(path string) (*Devbox, error) {
19+
dx, err := devbox.Open(&devopt.Opts{
20+
Dir: path,
21+
Stderr: io.Discard,
22+
})
23+
if err != nil {
24+
return nil, err
25+
}
26+
return &Devbox{dx: dx}, nil
27+
}
28+
29+
// Install downloads and installs missing packages.
30+
func (d *Devbox) Install(ctx context.Context) error {
31+
return d.dx.Install(ctx)
32+
}

docs/app/docs/devbox_examples/databases/mysql.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,16 @@ MYSQL_BASEDIR=.devbox/nix/profile/default
4646
MYSQL_HOME=./.devbox/virtenv/mysql/run
4747
MYSQL_DATADIR=./.devbox/virtenv/mysql/data
4848
MYSQL_UNIX_PORT=./.devbox/virtenv/mysql/run/mysql.sock
49-
MYSQL_PID_FILE=./.devbox/mysql/run/mysql.pid
49+
MYSQL_PID_FILE=./.devbox/virtenv/mysql/run/mysql.pid
50+
MYSQL_CONF=./devbox.d/mysql/my.cnf
5051
```
5152

5253
### Files
5354

55+
The following helper file will be created in your project directory:
56+
57+
* \{PROJECT_DIR\}/devbox.d/mysql/my.cnf
58+
5459
The plugin will also create the following helper files in your project's `.devbox/virtenv` folder:
5560

5661
* mysql/flake.nix

docs/app/docs/devbox_examples/languages/elixir.md

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,59 @@
22
title: Elixir
33
---
44

5-
Elixir can be configured to install Hex and Rebar dependencies in a local directory. This will keep Elixir from trying to install in your immutable Nix Store:
5+
Elixir can be installed by simply running `devbox add elixir`. This will automatically include the Elixir Plugin to isolate Mix/Hex artifacts and enable shell history in `iex`.
66

77
[**Example Repo**](https://github.com/jetify-com/devbox/tree/main/examples/development/elixir/elixir_hello)
88

99
[![Open In Devspace](../../../static/img/open-in-devspace.svg)](https://auth.jetify.com/devspace/templates/elixir/)
1010

1111
## Adding Elixir to your project
1212

13-
`devbox add elixir bash`, or add the following to your `devbox.json`
13+
`devbox add elixir`, or add the following to your `devbox.json`
1414

1515
```json
1616
"packages": [
17-
"elixir@latest",
18-
"bash@latest"
17+
"elixir@latest"
1918
],
2019
```
2120

22-
This will install the latest version of Elixir available. You can find other installable versions of Elixir by running `devbox search elixir`. You can also search for Elixir on [Nixhub](https://www.nixhub.io/packages/elixir)
21+
This will install the latest version of Elixir. You can find other installable versions of Elixir by running `devbox search elixir`. You can also search for Elixir on [Nixhub](https://www.nixhub.io/packages/elixir)
2322

24-
## Installing Hex and Rebar locally
23+
## Elixir Plugin Support
2524

26-
Since you are unable to install Elixir Deps directly into the Nix store, you will need to configure mix to install your dependencies globally. You can do this by adding the following lines to your `devbox.json` init_hook:
25+
Devbox will automatically use the following configuration when you install Elixir with `devbox add`.
26+
27+
### Environment Variables
28+
29+
`$MIX_HOME` and `$HEX_HOME` configure Mix/Hex to install artifacts locally, while `$ERL_AFLAGS` enables shell history in `iex`:
30+
31+
```bash
32+
MIX_HOME={PROJECT_DIR}/.devbox/virtenv/elixir/mix
33+
HEX_HOME={PROJECT_DIR}/.devbox/virtenv/elixir/hex
34+
ERL_AFLAGS="-kernel shell_history enabled"
35+
```
36+
37+
### Disabling the Elixir Plugin
38+
39+
You can disable the Elixir plugin by running `devbox add elixir --disable-plugin`, or by setting the `disable_plugin` field in your `devbox.json`:
2740

2841
```json
29-
"shell": {
30-
"init_hook": [
31-
"mkdir -p .nix-mix",
32-
"mkdir -p .nix-hex",
33-
"export MIX_HOME=$PWD/.nix-mix",
34-
"export HEX_HOME=$PWD/.nix-hex",
35-
"export ERL_AFLAGS='-kernel shell_history enabled'",
36-
"mix local.hex --force",
37-
"mix local.rebar --force"
38-
]
39-
}
42+
{
43+
"packages": {
44+
"elixir": {
45+
"version": "latest",
46+
"disable_plugin": true
47+
}
48+
},
49+
}
4050
```
4151

42-
This will create local folders and force mix to install your Hex and Rebar packages to those folders. Now when you are in `devbox shell`, you can install using `mix deps`.
52+
Note that disabling the plugin will cause Mix and Hex to cache artifacts globally in the user's home directory (at `~/.mix/` and `~/.hex/`). This might actually be preferable if you're developing several Elixir projects and want to benefit from caching, but does defeat the isolation guarantees of Devbox.
53+
54+
If the plugin is disabled, it's recommended to manually set `$ERL_AFLAGS` to preserve `iex` shell history:
55+
56+
```json
57+
"env": {
58+
"ERL_AFLAGS": "-kernel shell_history enabled"
59+
}
60+
```

docs/app/docs/guides/plugins.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This doc describes how to use Devbox Plugins with your project. **Plugins** prov
88

99
### Built-in Plugins
1010

11-
If you add one of the packages listed above to your project using `devbox add <pkg>`, Devbox will automatically activate the plugin for that package.
11+
If you add one of the packages listed below to your project using `devbox add <pkg>`, Devbox will automatically activate the plugin for that package.
1212

1313
You can also explicitly add a built-in plugin in your project by adding it to the [`include` section](../configuration.md#include) of your `devbox.json` file. For example, to explicitly add the plugin for Nginx, you can add the following to your `devbox.json` file:
1414

@@ -34,6 +34,7 @@ Built-in plugins are available for the following packages. You can activate the
3434
* [PHP](../devbox_examples/languages/php.md) (php, php80, php81, php82...)
3535
* [Python](../devbox_examples/languages/python.md) (python, python-full, python-minimal...)
3636
* [Ruby](../devbox_examples/languages/ruby.md)(ruby, ruby_3_1, ruby_3_0...)
37+
* [Elixir](../devbox_examples/languages/elixir.md)(elixir, elixir_1_16, elixir_1_15...)
3738

3839

3940
### Local Plugins
@@ -56,6 +57,8 @@ Sometimes, you may want to share a plugin across multiple projects or users. In
5657
]
5758
```
5859

60+
Note that Devbox will cache Github plugins for 24 hours. This is to aid performance of `devbox shell` and similar commands, and avoids downloading the plugin from Github each time. In extenuating circumstances, you can bypass this cache by setting `export DEVBOX_X_GITHUB_PLUGIN_CACHE_TTL=<time>` , where time is a valid input to `time.ParseDuration` (see [doc](https://pkg.go.dev/time#ParseDuration)) such as "120s" or "2m".
61+
5962
## An Example of a Plugin: Nginx
6063
Let's take a look at the plugin for Nginx. To get started, let's initialize a new devbox project, and add the `nginx` package:
6164

docs/app/docs/installing_devbox.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ curl -fsSL https://get.jetify.com/devbox | bash
2020

2121
Devbox requires the [Nix Package Manager](https://nixos.org/download.html). If Nix is not detected when running a command, Devbox will install it for you in single-user mode for Linux. Don't worry: You can use Devbox without needing to learn the Nix Language.
2222

23-
If you would like to install Nix yourself, we recommend the [Determinate Nix Installer](https://determinate.systems/posts/determinate-nix-installer/).
23+
If you would like to install Nix yourself, we recommend the [Determinate Nix Installer](https://determinate.systems/nix-installer/).
2424

2525
</TabItem>
2626
<TabItem value="macos" label="MacOS">

docs/app/pnpm-lock.yaml

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/databases/postgres/devbox.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"packages": {
3-
"postgresql": "latest",
4-
"glibcLocales": {
5-
"version": "latest",
6-
"platforms": ["x86_64-linux", "aarch64-linux"]
7-
}
3+
"postgresql": "latest"
84
},
95
"shell": {
106
"init_hook": null

examples/development/elixir/elixir_hello/devbox.json

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
{
2-
"packages": {
3-
"elixir": "latest"
4-
},
5-
"env": {
6-
"MIX_HOME": "$PWD/.nix-mix",
7-
"HEX_HOME": "$PWD/.nix-hex",
8-
"ERL_AFLAGS": "-kernel shell_history enabled"
9-
},
2+
"packages": [
3+
"elixir@latest"
4+
],
105
"shell": {
116
"init_hook": [
12-
"mkdir -p .nix-mix",
13-
"mkdir -p .nix-hex",
14-
"mix local.hex --force",
15-
"mix local.rebar --force",
167
"mix deps.get"
178
],
189
"scripts": {

examples/development/elixir/elixir_hello/devbox.lock

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,51 @@
22
"lockfile_version": "1",
33
"packages": {
44
"elixir@latest": {
5-
"last_modified": "2024-02-10T18:15:24Z",
6-
"resolved": "github:NixOS/nixpkgs/10b813040df67c4039086db0f6eaf65c536886c6#elixir",
5+
"last_modified": "2024-11-28T07:51:56Z",
6+
"plugin_version": "0.0.1",
7+
"resolved": "github:NixOS/nixpkgs/226216574ada4c3ecefcbbec41f39ce4655f78ef#elixir",
78
"source": "devbox-search",
8-
"version": "1.15.7",
9+
"version": "1.17.3",
910
"systems": {
1011
"aarch64-darwin": {
1112
"outputs": [
1213
{
1314
"name": "out",
14-
"path": "/nix/store/kf294q6pwmqv8hb5ivis509y1wjjgm09-elixir-1.15.7",
15+
"path": "/nix/store/91w79z55qsjkhnbs3a21l3h27va98mf6-elixir-1.17.3",
1516
"default": true
1617
}
1718
],
18-
"store_path": "/nix/store/kf294q6pwmqv8hb5ivis509y1wjjgm09-elixir-1.15.7"
19+
"store_path": "/nix/store/91w79z55qsjkhnbs3a21l3h27va98mf6-elixir-1.17.3"
1920
},
2021
"aarch64-linux": {
2122
"outputs": [
2223
{
2324
"name": "out",
24-
"path": "/nix/store/f5x2w7df45vahjcpjf76dv101il8xq98-elixir-1.15.7",
25+
"path": "/nix/store/pz4hk0sp4zj76waaprlfdmvc4xdblz55-elixir-1.17.3",
2526
"default": true
2627
}
2728
],
28-
"store_path": "/nix/store/f5x2w7df45vahjcpjf76dv101il8xq98-elixir-1.15.7"
29+
"store_path": "/nix/store/pz4hk0sp4zj76waaprlfdmvc4xdblz55-elixir-1.17.3"
2930
},
3031
"x86_64-darwin": {
3132
"outputs": [
3233
{
3334
"name": "out",
34-
"path": "/nix/store/6vv8qlvhpi62nk5d06lhi5isvlg7bcj9-elixir-1.15.7",
35+
"path": "/nix/store/gnjg57wv71svvqw7s3rxyjc6lkps2r95-elixir-1.17.3",
3536
"default": true
3637
}
3738
],
38-
"store_path": "/nix/store/6vv8qlvhpi62nk5d06lhi5isvlg7bcj9-elixir-1.15.7"
39+
"store_path": "/nix/store/gnjg57wv71svvqw7s3rxyjc6lkps2r95-elixir-1.17.3"
3940
},
4041
"x86_64-linux": {
4142
"outputs": [
4243
{
4344
"name": "out",
44-
"path": "/nix/store/dlq14nswvq479pmnrwlyn2hyk6cwp65a-elixir-1.15.7",
45+
"path": "/nix/store/rx7qr8bar4qldx6yg3njvm8hn84d3yyk-elixir-1.17.3",
4546
"default": true
4647
}
4748
],
48-
"store_path": "/nix/store/dlq14nswvq479pmnrwlyn2hyk6cwp65a-elixir-1.15.7"
49+
"store_path": "/nix/store/rx7qr8bar4qldx6yg3njvm8hn84d3yyk-elixir-1.17.3"
4950
}
5051
}
5152
}

0 commit comments

Comments
 (0)