String interpolating a relative or absolute path value will cause Nix to copy the contents at that path to the store before constructing the string. (NixOS/nix#9428)
- This has I/O implications for evaluation times, especially for large files/directories
- This will error out if the path does not exist or if the user lacks permissions to view it
- In a flake-controlled project (which is already copied as part of evaluation), this creates duplicate store objects
Solutions:
- Avoid string interpolating path values. Use
builtins.toStringif you need the values to be a string. - Avoid using path values in general, and prefer using a generic string (
"/var/empty"instead of/var/empty)
nix-repl> "${/var/empty}"
"/nix/store/<hash>-empty"
nix-repl> toString /var/empty
"/var/empty"