docs(nix): remove unobserved let rule

This commit is contained in:
2026-08-28 10:18:34 -04:00
parent 71570edeaa
commit 09aee329cf

View File

@@ -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.