Skip to content

Commit

Permalink
Merge pull request NixOS#790 from wamirez/master
Browse files Browse the repository at this point in the history
rephrase best practices for clarity
  • Loading branch information
proofconstruction committed Nov 6, 2023
2 parents 3f5c86d + b1ae5e4 commit 51e43e3
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions source/guides/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down

0 comments on commit 51e43e3

Please sign in to comment.