docs(nix): remove unobserved let rule
This commit is contained in:
25
docs/nix.md
25
docs/nix.md
@@ -154,31 +154,6 @@ in
|
||||
lib.genAttrs hostNames mkHost
|
||||
```
|
||||
|
||||
### Bind shared expressions once
|
||||
|
||||
Use a `let` binding when sibling expressions depend on the same derived value.
|
||||
|
||||
Avoid:
|
||||
|
||||
```nix
|
||||
{
|
||||
hostNames = lib.attrNames hosts;
|
||||
hostCount = lib.length (lib.attrNames hosts);
|
||||
}
|
||||
```
|
||||
|
||||
Use:
|
||||
|
||||
```nix
|
||||
let
|
||||
hostNames = lib.attrNames hosts;
|
||||
in
|
||||
{
|
||||
inherit hostNames;
|
||||
hostCount = lib.length hostNames;
|
||||
}
|
||||
```
|
||||
|
||||
### Keep bindings in the smallest scope
|
||||
|
||||
Place a `let` binding inside the expression that consumes it.
|
||||
|
||||
Reference in New Issue
Block a user