aboutsummaryrefslogtreecommitdiff
path: root/tests/lang/eval-okay-ind-string.nix
AgeCommit message (Collapse)Author
2023-01-02antiquotation -> string interpolationValentin Gagarin
as proposed by @mkaito[1] and @tazjin[2] and discussed with @edolstra and Nix maintainers [1]: https://github.com/NixOS/nix.dev/pull/267#issuecomment-1270076332 [2]: https://github.com/NixOS/nix.dev/pull/267#issuecomment-1270201979 Co-authored-by: John Ericson <git@JohnEricson.me> Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2017-05-01Fix lexer to support `$'` in multiline strings.Guillaume Maudoux
2008-02-05* Regression test.Eelco Dolstra
2007-12-06* Syntax to escape '', ${.Eelco Dolstra
2007-11-30* Added a new kind of multi-line string literal delimited by twoEelco Dolstra
single quotes. Example (from NixOS): job = '' start on network-interfaces start script rm -f /var/run/opengl-driver ${if videoDriver == "nvidia" then "ln -sf ${nvidiaDrivers} /var/run/opengl-driver" else if cfg.driSupport then "ln -sf ${mesa} /var/run/opengl-driver" else "" } rm -f /var/log/slim.log end script ''; This style has two big advantages: - \, ' and " aren't special, only '' and ${. So you get a lot less escaping in shell scripts / configuration files in Nixpkgs/NixOS. The delimiter '' is rare in scripts (and can usually be written as ""). ${ is also fairly rare. Other delimiters such as <<...>>, {{...}} and <|...|> were also considered but this one appears to have the fewest drawbacks (thanks Martin). - Indentation is intelligently stripped so that multi-line strings can follow the nesting structure of the containing Nix expression. E.g. in the example above 6 spaces are stripped from the start of each line. This prevents unnecessary indentation in generated files (which sometimes even breaks things). See tests/lang/eval-okay-ind-string.nix for some examples.