Flakes: Difference between revisions

imported>Mic92
No edit summary
imported>Mic92
No edit summary
Line 32: Line 32:
</syntaxHighlight>
</syntaxHighlight>


Edit either ~/.config/nix/nix.conf or /etc/nix/nix.conf and add:
Edit either <code>~/.config/nix/nix.conf</code> or <code>/etc/nix/nix.conf</code> and add:


<syntaxHighlight>
<syntaxHighlight>
Line 215: Line 215:
=== Direnv integration ===
=== Direnv integration ===


Assuming that the flake defines a devShell output attribute and that you are using direnv. Here is how to replace the old use nix stdlib function with the faster flake version:
Assuming that the flake defines a <code>devShell</code> output attribute and that you are using direnv. Here is how to replace the old use nix stdlib function with the faster flake version:


<syntaxHighlight lang=sh>
<syntaxHighlight lang=sh>
Line 225: Line 225:
</syntaxHighlight>
</syntaxHighlight>


Copy this in ~/.config/direnv/lib/use_flake.sh or in ~/.config/direnv/direnvrc
Copy this in <code>~/.config/direnv/lib/use_flake.sh</code> or in <code>~/.config/direnv/direnvrc</code>
or directly in your project specific <code>.envrc</code>.
or directly in your project specific <code>.envrc</code>.


With this in place, you can now replace the use nix invocation in the .envrc file with use flake.
With this in place, you can now replace the use nix invocation in the <code>.envrc</code> file with <code>use flake<code>:
 
<syntaxHighlight>
# .envrc
use flake
</syntaxHighlight>


The nice thing about this approach is that evaluation is cached, and that the project’s shell is now protected from the nix garbage-collector.
The nice thing about this approach is that evaluation is cached, and that the project’s shell is now protected from the nix garbage-collector.