1
0
Fork 0
mirror of https://github.com/NixOS/nix.dev.git synced 2024-10-18 14:32:43 -04:00

rephrase best practices for clarity

This commit is contained in:
wamirez 2023-11-06 12:23:27 -04:00
parent 3f5c86d466
commit b1ae5e47fc

View file

@ -31,10 +31,8 @@ rec {
{ a = 1; b = 3; }
```
There are a couple of pitfalls:
- It's possible to introduce a hard to debug error `infinite recursion` when shadowing a name, the simplest example being `let b = 1; a = rec { b = b; }; in a`.
- Combining with overriding logic such as the [`overrideAttrs`](https://nixos.org/manual/nixpkgs/stable/#sec-pkg-overrideAttrs) function in {term}`Nixpkgs` has a surprising behaviour of not overriding every reference.
A common pitfall is to introduce a hard to debug error `infinite recursion` when shadowing a name.
The simplest example for this is: `let a = 1; in rec { a = a; }`.
:::{tip}
Avoid `rec`. Use `let ... in`.