Direnv: Difference between revisions
Moved from the nix-shell article. (with significant improvements) |
Nix support stuff |
||
Line 1: | Line 1: | ||
'''[https://direnv.net Direnv]''' is an automatic environment setup utility, loading the specified project environment automatically when you enter your project directory, and reporting the loaded variables to you. | '''[https://direnv.net Direnv]''' is an automatic environment setup utility, loading the specified project environment automatically when you enter your project directory, and reporting the loaded variables to you. | ||
After installing {{nixos:package|direnv}} from Nixpkgs using your preferred method of installation, you can set up the <code>.envrc</code> file at the root of your directory. Refer to the [https://github.com/direnv/direnv/wiki Direnv Wiki] for some examples. | After installing {{nixos:package|direnv}} from Nixpkgs using your preferred method of installation, you can set up the <code>.envrc</code> file at the root of your directory. Refer to the [https://github.com/direnv/direnv/wiki Direnv Wiki] for some examples. For Nix projects, you will probably want to use the special <code>use_nix</code> keyword, that automatically loads the <code>shell.nix</code> file for your repository. | ||
At the root of your repository, Direnv can start by allowing the recently-created <code>.envrc</code> file to execute: | At the root of your repository, Direnv can start by allowing the recently-created <code>.envrc</code> file to execute: | ||
Line 24: | Line 24: | ||
Keeping that directory means that an <code>.envrc</code> file only needs to be allowed once in order to run automatically. | Keeping that directory means that an <code>.envrc</code> file only needs to be allowed once in order to run automatically. | ||
== <code>nix-direnv</code> & <code>lorri</code> == | |||
While Direnv has [https://github.com/direnv/direnv/wiki/Nix full support for Nix] development environments, third-party developers have improved upon Direnv's default implementation of the special <code>use_nix</code> keyword, resulting in the development of [https://github.com/nix-community/nix-direnv <code>nix-direnv</code>] and [https://github.com/nix-community/lorri <code>lorri</code>]. | |||
The NixOS module uses <code>nix-direnv</code> by default when Direnv is enabled, but this can be overriden with the {{nixos:option|programs.direnv.nix-direnv.package}} option. | |||
== Configuring on NixOS == | == Configuring on NixOS == |