2022-01-23 20:38:27 +01:00
|
|
|
← [[doom-module-index:][Back to module index]] ! [[doom-module-issues:::tools direnv][Issues]] ↖ [[doom-repo:tree/develop/modules/tools/direnv/][Github]] ± [[doom-suggest-edit:][Suggest edits]] ? [[doom-help-modules:][Help]]
|
2021-10-16 01:29:27 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
#+TITLE: :tools direnv
|
|
|
|
#+SUBTITLE: Save (or destroy) the environment at your leisure
|
|
|
|
#+CREATED: April 05, 2019
|
|
|
|
#+SINCE: 21.12.0
|
|
|
|
|
|
|
|
* Description :unfold:
|
2019-08-27 12:50:10 -04:00
|
|
|
This module integrates direnv into Emacs.
|
|
|
|
|
|
|
|
#+begin_quote
|
2021-10-16 01:29:27 +02:00
|
|
|
📌 direnv is an environment switcher for the shell. It knows how to hook into
|
|
|
|
bash, zsh, tcsh, fish shell and elvish to load or unload environment
|
|
|
|
variables depending on the current directory. This allows project-specific
|
|
|
|
environment variables without cluttering the ~/.profile file.
|
|
|
|
|
|
|
|
Before each prompt, direnv checks for the existence of a ".envrc" file in
|
|
|
|
the current and parent directories. If the file exists (and is authorized),
|
|
|
|
it is loaded into a bash sub-shell and all exported variables are then
|
|
|
|
captured by direnv and then made available to the current shell.
|
2019-08-27 12:50:10 -04:00
|
|
|
#+end_quote
|
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
** Maintainers
|
|
|
|
- [[doom-user:][@hlissner]]
|
|
|
|
|
|
|
|
[[doom-contrib-maintainer:][Become a maintainer?]]
|
2019-08-27 12:50:10 -04:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
** Module flags
|
|
|
|
/This module has no flags./
|
|
|
|
|
|
|
|
** Packages
|
|
|
|
- [[doom-package:][envrc]]
|
2019-08-27 12:50:10 -04:00
|
|
|
|
|
|
|
** Hacks
|
2021-10-16 01:29:27 +02:00
|
|
|
- ~envrc-mode~ has been modified to fail gracefully if ~direnv~ isn't available.
|
|
|
|
- ~envrc-global-mode~ has been modified to activate envrc-mode sooner in the
|
|
|
|
major mode activation process, so that any env state performed in mode hooks
|
|
|
|
aren't overwritten by direnv.
|
|
|
|
- Added direnv support for Org src blocks.
|
|
|
|
|
|
|
|
** TODO Changelog
|
|
|
|
# This section will be machine generated. Don't edit it by hand.
|
|
|
|
/This module does not have a changelog yet./
|
2019-08-27 12:50:10 -04:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
* Installation
|
|
|
|
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
|
|
|
|
|
|
|
This module requires [[https://direnv.net/][direnv]].
|
2019-08-27 12:50:10 -04:00
|
|
|
|
|
|
|
** MacOS
|
2021-10-16 01:29:27 +02:00
|
|
|
#+begin_src sh
|
2019-08-27 12:50:10 -04:00
|
|
|
brew install direnv
|
2021-10-16 01:29:27 +02:00
|
|
|
#+end_src
|
2019-08-27 12:50:10 -04:00
|
|
|
|
|
|
|
** Arch Linux
|
2021-10-16 01:29:27 +02:00
|
|
|
~direnv~ is available on the AUR:
|
|
|
|
#+begin_src sh
|
2020-09-05 10:14:16 +03:00
|
|
|
yay -S direnv
|
2021-10-16 01:29:27 +02:00
|
|
|
#+end_src
|
2019-08-27 12:50:10 -04:00
|
|
|
|
|
|
|
** NixOS
|
2021-10-16 01:29:27 +02:00
|
|
|
#+begin_src nix
|
2019-08-27 12:50:10 -04:00
|
|
|
environment.systemPackages = [ pkgs.direnv ];
|
2021-10-16 01:29:27 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
Or ~$ nix-env -i direnv~
|
|
|
|
|
|
|
|
* TODO Usage
|
|
|
|
#+begin_quote
|
|
|
|
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
|
|
|
#+end_quote
|
2019-08-27 12:50:10 -04:00
|
|
|
|
2021-10-16 01:29:27 +02:00
|
|
|
To make use of direnv you need a =.envrc= file in a directory. Any time you open
|
|
|
|
a file or buffer in said directory, the [[doom-package:][envrc]] Emacs package will kick in,
|
|
|
|
activate the local env, and inject it into Emacs for the current buffer.
|
|
|
|
|
|
|
|
* TODO Configuration
|
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]]
|
|
|
|
#+end_quote
|
2019-08-27 12:50:10 -04:00
|
|
|
|
|
|
|
* Troubleshooting
|
2021-10-16 01:29:27 +02:00
|
|
|
[[doom-report:][Report an issue?]]
|
|
|
|
|
2019-08-27 12:50:10 -04:00
|
|
|
** direnv + nix is slow
|
2021-08-02 21:36:12 -06:00
|
|
|
Consider augmenting direnv with [[https://github.com/nix-community/lorri][lorri]], which will cache nix builds and speed up
|
2020-01-09 15:19:52 -05:00
|
|
|
direnv tremendously:
|
2021-10-16 01:29:27 +02:00
|
|
|
#+begin_src nix
|
2020-01-09 15:19:52 -05:00
|
|
|
services.lorri.enable = true;
|
2021-10-16 01:29:27 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* Frequently asked questions
|
|
|
|
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
|
|
|
|
|
|
|
|
* TODO Appendix
|
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
|
|
|
#+end_quote
|