Nix strings

Simple strings

Strings in Nix can be written with double quotes, and can span multiple lines:

"some string"

Within simple strings, the special characters ", \, and the antiquotation sequence ${ must be escaped with a leading \. Standard whitespace escape sequences \n, \r, and \t work as expected.

Indented strings

Indented strings are written between double single quotes:

  This is some longer
  string that spans
  multiple lines.

These strings strip the minimal indentation from each line.

Within indented strings, some additional character escaping is necessary.

  • $ -> ''$
  • '' -> '''
  • \n -> ''\n (and so on for other escape sequences)


A URI is also a string, though it can be written without quotes.