diff --git a/docs/integration/third_party/direnv.md b/docs/integration/third_party/direnv.md new file mode 100644 index 0000000000..f6a666a8e1 --- /dev/null +++ b/docs/integration/third_party/direnv.md @@ -0,0 +1,36 @@ + +??? note "Installing direnv" + + Of course you can use `pixi` to install `direnv` globally. We recommend to run + + ```bash + pixi global install direnv + ``` + + to install the latest version of `direnv` on your computer. + +You can use `pixi` in combination with `direnv` to automatically activate environments on entering the corresponding directory. +Enter the following into your `.envrc` file: + +```shell title=".envrc" +watch_file pixi.lock # (1)! +eval "$(pixi shell-hook)" # (2)! +``` + +1. This ensures that every time your `pixi.lock` changes, `direnv` invokes the shell-hook again. +2. This installs if needed, and activates the environment. `direnv` ensures that the environment is deactivated when you leave the directory. + +```shell +$ cd my-project +direnv: error /my-project/.envrc is blocked. Run `direnv allow` to approve its content +$ direnv allow +direnv: loading /my-project/.envrc +✔ Project in /my-project is ready to use! +direnv: export +CONDA_DEFAULT_ENV +CONDA_PREFIX +PIXI_ENVIRONMENT_NAME +PIXI_ENVIRONMENT_PLATFORMS +PIXI_PROJECT_MANIFEST +PIXI_PROJECT_NAME +PIXI_PROJECT_ROOT +PIXI_PROJECT_VERSION +PIXI_PROMPT ~PATH +$ which python +/my-project/.pixi/envs/default/bin/python +$ cd .. +direnv: unloading +$ which python +python not found +``` diff --git a/docs/workspace/environment.md b/docs/workspace/environment.md index 04ecd36c57..e37486590b 100644 --- a/docs/workspace/environment.md +++ b/docs/workspace/environment.md @@ -133,43 +133,8 @@ $ (default) which python !!! warning It is not encouraged to use the traditional `conda activate`-like activation, as deactivating the environment is not really possible. Use `pixi shell` instead. -### Using `pixi` with `direnv` - -??? note "Installing direnv" - - Of course you can use `pixi` to install `direnv` globally. We recommend to run - - ``` - pixi global install direnv - ``` - - to install the latest version of `direnv` on your computer. - -This allows you to use `pixi` in combination with `direnv`. -Enter the following into your `.envrc` file: - -```shell title=".envrc" -watch_file pixi.lock # (1)! -eval "$(pixi shell-hook)" # (2)! -``` - -1. This ensures that every time your `pixi.lock` changes, `direnv` invokes the shell-hook again. -2. This installs if needed, and activates the environment. `direnv` ensures that the environment is deactivated when you leave the directory. - -```shell -$ cd my-project -direnv: error /my-project/.envrc is blocked. Run `direnv allow` to approve its content -$ direnv allow -direnv: loading /my-project/.envrc -✔ Project in /my-project is ready to use! -direnv: export +CONDA_DEFAULT_ENV +CONDA_PREFIX +PIXI_ENVIRONMENT_NAME +PIXI_ENVIRONMENT_PLATFORMS +PIXI_PROJECT_MANIFEST +PIXI_PROJECT_NAME +PIXI_PROJECT_ROOT +PIXI_PROJECT_VERSION +PIXI_PROMPT ~PATH -$ which python -/my-project/.pixi/envs/default/bin/python -$ cd .. -direnv: unloading -$ which python -python not found -``` +!!! tip "" + See our [direnv page](../integration/third_party/direnv.md) on how to leverage `pixi shell-hook` to integrate with direnv. ## Environment variables diff --git a/mkdocs.yml b/mkdocs.yml index 59fb46cc93..a64d613e08 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -141,6 +141,7 @@ nav: - GitHub Actions: integration/ci/github_actions.md - Lockfile Updates: integration/ci/updates_github_actions.md - Third Party: + - Direnv: integration/third_party/direnv.md - Pixi Diff: integration/third_party/pixi_diff.md - Starship: integration/third_party/starship.md - Switching from: