E015: Invalid String Interpolation
Severity: Error
`int` cannot be used in string interpolation; use `toString` to convert it explicitly
A value of a type that Nix cannot interpolate was used inside "${...}". Nix string interpolation only works for:
- strings (identity)
- paths (converted to absolute path string)
- derivations (attrsets with
outPath— converted to store path)
It does not work for int, bool, float, null, lists, or functions — these cause a runtime error like cannot coerce an integer to a string.
How to fix
Wrap the expression in toString:
# Before (E015):
"count: ${1 + 2}"
# After:
"count: ${toString (1 + 2)}"
The LSP offers a quick fix to insert toString automatically.