diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-11-30T16·48+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2007-11-30T16·48+0000 |
commit | 6d6c68c0d29310b6eca35f58b1e68f495d6cd33a (patch) | |
tree | eec6c3c138951f1f0cb3f9b4b1f3b3c177c31afb /src/libexpr/nixexpr-ast.def | |
parent | 633518628f48fb9c06bfd570eeca6f62696aba05 (diff) |
* Added a new kind of multi-line string literal delimited by two
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.
Diffstat (limited to 'src/libexpr/nixexpr-ast.def')
-rw-r--r-- | src/libexpr/nixexpr-ast.def | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libexpr/nixexpr-ast.def b/src/libexpr/nixexpr-ast.def index c7029e927047..a06d34311ae1 100644 --- a/src/libexpr/nixexpr-ast.def +++ b/src/libexpr/nixexpr-ast.def @@ -46,6 +46,9 @@ Int | int | Expr | Str | string ATermList | Expr | Str | string | Expr | ObsoleteStr +# Internal to the parser, doesn't occur in ASTs. +IndStr | string | Expr | + # A path is a reference to a file system object that is to be copied # to the Nix store when used as a derivation attribute. When it is # concatenated to a string (i.e., `str + path'), it is also copied and |