diff --git a/.schema/devbox.schema.json b/.schema/devbox.schema.json index 41c3ffd3534..f540406976e 100644 --- a/.schema/devbox.schema.json +++ b/.schema/devbox.schema.json @@ -139,7 +139,16 @@ }, "env_from": { "type": "string" + }, + "nixpkgs": { + "type": "object", + "properties": { + "commit": { + "type": "string", + "description": "The commit hash of the nixpkgs repository to use" + } + } } }, "additionalProperties": false -} \ No newline at end of file +} diff --git a/docs/app/docs/devbox_examples/databases/mysql.md b/docs/app/docs/devbox_examples/databases/mysql.md index 4d73d5594ac..a4fd9ccab41 100644 --- a/docs/app/docs/devbox_examples/databases/mysql.md +++ b/docs/app/docs/devbox_examples/databases/mysql.md @@ -46,11 +46,16 @@ MYSQL_BASEDIR=.devbox/nix/profile/default MYSQL_HOME=./.devbox/virtenv/mysql/run MYSQL_DATADIR=./.devbox/virtenv/mysql/data MYSQL_UNIX_PORT=./.devbox/virtenv/mysql/run/mysql.sock -MYSQL_PID_FILE=./.devbox/mysql/run/mysql.pid +MYSQL_PID_FILE=./.devbox/virtenv/mysql/run/mysql.pid +MYSQL_CONF=./devbox.d/mysql/my.cnf ``` ### Files +The following helper file will be created in your project directory: + +* \{PROJECT_DIR\}/devbox.d/mysql/my.cnf + The plugin will also create the following helper files in your project's `.devbox/virtenv` folder: * mysql/flake.nix diff --git a/docs/app/docs/devbox_examples/languages/elixir.md b/docs/app/docs/devbox_examples/languages/elixir.md index ef746fd159e..c0ba80ef44a 100644 --- a/docs/app/docs/devbox_examples/languages/elixir.md +++ b/docs/app/docs/devbox_examples/languages/elixir.md @@ -2,7 +2,7 @@ title: Elixir --- -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: +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`. [**Example Repo**](https://github.com/jetify-com/devbox/tree/main/examples/development/elixir/elixir_hello) @@ -10,33 +10,51 @@ Elixir can be configured to install Hex and Rebar dependencies in a local direct ## Adding Elixir to your project -`devbox add elixir bash`, or add the following to your `devbox.json` +`devbox add elixir`, or add the following to your `devbox.json` ```json "packages": [ - "elixir@latest", - "bash@latest" + "elixir@latest" ], ``` -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) +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) -## Installing Hex and Rebar locally +## Elixir Plugin Support -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: +Devbox will automatically use the following configuration when you install Elixir with `devbox add`. + +### Environment Variables + +`$MIX_HOME` and `$HEX_HOME` configure Mix/Hex to install artifacts locally, while `$ERL_AFLAGS` enables shell history in `iex`: + +```bash +MIX_HOME={PROJECT_DIR}/.devbox/virtenv/elixir/mix +HEX_HOME={PROJECT_DIR}/.devbox/virtenv/elixir/hex +ERL_AFLAGS="-kernel shell_history enabled" +``` + +### Disabling the Elixir Plugin + +You can disable the Elixir plugin by running `devbox add elixir --disable-plugin`, or by setting the `disable_plugin` field in your `devbox.json`: ```json - "shell": { - "init_hook": [ - "mkdir -p .nix-mix", - "mkdir -p .nix-hex", - "export MIX_HOME=$PWD/.nix-mix", - "export HEX_HOME=$PWD/.nix-hex", - "export ERL_AFLAGS='-kernel shell_history enabled'", - "mix local.hex --force", - "mix local.rebar --force" - ] - } +{ + "packages": { + "elixir": { + "version": "latest", + "disable_plugin": true + } + }, +} ``` -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`. +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. + +If the plugin is disabled, it's recommended to manually set `$ERL_AFLAGS` to preserve `iex` shell history: + +```json + "env": { + "ERL_AFLAGS": "-kernel shell_history enabled" + } +``` \ No newline at end of file diff --git a/docs/app/docs/guides/plugins.md b/docs/app/docs/guides/plugins.md index ca73e44beb3..1625de1ed25 100644 --- a/docs/app/docs/guides/plugins.md +++ b/docs/app/docs/guides/plugins.md @@ -8,7 +8,7 @@ This doc describes how to use Devbox Plugins with your project. **Plugins** prov ### Built-in Plugins -If you add one of the packages listed above to your project using `devbox add `, Devbox will automatically activate the plugin for that package. +If you add one of the packages listed below to your project using `devbox add `, Devbox will automatically activate the plugin for that package. 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: @@ -34,6 +34,7 @@ Built-in plugins are available for the following packages. You can activate the * [PHP](../devbox_examples/languages/php.md) (php, php80, php81, php82...) * [Python](../devbox_examples/languages/python.md) (python, python-full, python-minimal...) * [Ruby](../devbox_examples/languages/ruby.md)(ruby, ruby_3_1, ruby_3_0...) +* [Elixir](../devbox_examples/languages/elixir.md)(elixir, elixir_1_16, elixir_1_15...) ### Local Plugins @@ -56,6 +57,8 @@ Sometimes, you may want to share a plugin across multiple projects or users. In ] ``` +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=