mirror of
https://github.com/NixOS/nix
synced 2025-07-02 21:51:50 +02:00
nix-shell: Execute shellHook if it exists
Since normal builds don't execute shellHook, this allows nix-shell specific customisation. Suggested by Domen.
This commit is contained in:
parent
832377bbd6
commit
e81d38c02b
2 changed files with 17 additions and 0 deletions
|
@ -51,6 +51,22 @@ derivation for development.</para>
|
|||
<filename>shell.nix</filename> if it exists, and
|
||||
<filename>default.nix</filename> otherwise.</para>
|
||||
|
||||
<para>If the derivation defines the variable
|
||||
<varname>shellHook</varname>, it will be evaluated after
|
||||
<literal>$stdenv/setup</literal> has been sourced. Since this hook is
|
||||
not executed by regular Nix builds, it allows you to perform
|
||||
initialisation specific to <command>nix-shell</command>. For example,
|
||||
the derivation attribute
|
||||
|
||||
<programlisting>
|
||||
shellHook =
|
||||
''
|
||||
echo "Hello shell!"
|
||||
'';
|
||||
</programlisting>
|
||||
|
||||
will cause <command>nix-shell</command> to print <literal>Hello shell!</literal>.</para>
|
||||
|
||||
</refsection>
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue