about summary refs log tree commit diff
path: root/tests/lang
AgeCommit message (Collapse)AuthorFilesLines
2010-05-07 * Sync with the trunk.Eelco Dolstra4-0/+4
2010-04-22 * Check for duplicate attribute names / function arguments. `makeEelco Dolstra3-1/+10
check' now succeeds :-) * An attribute set such as `{ foo = { enable = true; }; foo.port = 23; }' now parses. It was previously rejected, but I'm too lazy to implement the check. (The only reason to reject it is that the reverse, `{ foo.port = 23; foo = { enable = true; }; }', is rejected, which is kind of ugly.)
2010-04-21 * Update the expected test output (no longer an ATerm).Eelco Dolstra34-34/+34
2010-04-21 * Because --parse-only no longer produces an ATerm, don't check theEelco Dolstra5-5/+0
output. Whether it parses at all should be enough.
2010-03-31 (no commit message)Eelco Dolstra1-1/+0
2010-03-31 * Fix the broken test for listToAttrs.Eelco Dolstra2-2/+5
2010-03-31 Make source location info in the XML output optional.Ludovic Courtès2-0/+4
* src/libexpr/expr-to-xml.cc (nix::showAttrs): Add `location' parameter. Provide location XML attributes when it's true. Update callers. (nix::printTermAsXML): Likewise. * src/libexpr/expr-to-xml.hh (nix::printTermAsXML): Update prototype; have `location' default to `false'. * src/nix-instantiate/nix-instantiate.cc (printResult, processExpr): Add `location' parameter; update callers. (run): Add support for `--no-location'. * src/nix-instantiate/help.txt: Update accordingly. * tests/lang.sh: Invoke `nix-instantiate' with `--no-location' for the XML tests. * tests/lang/eval-okay-toxml.exp, tests/lang/eval-okay-to-xml.nix: New files.
2010-03-25 * Simplify @-patterns: only `{attrs}@name' or `name@{attrs}' are nowEelco Dolstra6-17/+10
allowed. So `name1@name2', `{attrs1}@{attrs2}' and so on are now no longer legal. This is no big loss because they were not useful anyway. This also changes the output of builtins.toXML for @-patterns slightly.
2010-03-23 * Doh.Eelco Dolstra2-20/+8
2010-03-23 * Test "with as; with bs;" since nobody knows what its semantics is.Eelco Dolstra1-1/+19
2009-09-15 * Two primops: builtins.intersectAttrs and builtins.functionArgs.Eelco Dolstra2-0/+95
intersectAttrs returns the (right-biased) intersection between two attribute sets, e.g. every attribute from the second set that also exists in the first. functionArgs returns the set of attributes expected by a function. The main goal of these is to allow the elimination of most of all-packages.nix. Most package instantiations in all-packages.nix have this form: foo = import ./foo.nix { inherit a b c; }; With intersectAttrs and functionArgs, this can be written as: foo = callPackage (import ./foo.nix) { }; where callPackage = f: args: f ((builtins.intersectAttrs (builtins.functionArgs f) pkgs) // args); I.e., foo.nix is called with all attributes from "pkgs" that it actually needs (e.g., pkgs.a, pkgs.b and pkgs.c). (callPackage can do any other generic package-level stuff we might want, such as applying makeOverridable.) Of course, the automatically supplied arguments can be overriden if needed, e.g. foo = callPackage (import ./foo.nix) { c = c_version_2; }; but for the vast majority of packages, this won't be needed. The advantages are to reduce the amount of typing needed to add a dependency (from three sites to two), and to reduce the number of trivial commits to all-packages.nix. For the former, there have been two previous attempts: - Use "args: with args;" in the package's function definition. This however obscures the actual expected arguments of a function, which is very bad. - Use "{ arg1, arg2, ... }:" in the package's function definition (i.e. use the ellipis "..." to allow arbitrary additional arguments), and then call the function with all of "pkgs" as an argument. But this inhibits error detection if you call it with an misspelled (or obsolete) argument.
2009-05-15 * Change the scoping of "inherit (e) ..." in recs so that theEelco Dolstra2-0/+7
attributes of the rec are in scope of `e'. This is useful in expressions such as rec { lib = import ./lib; inherit (lib) concatStrings; } It does change the semantics of expressions such as let x = {y = 1;}; in rec { x = {y = 2;}; inherit (x) y; }.y This now returns 2 instead of 1. However, no code in Nixpkgs or NixOS seems to rely on the old behaviour.
2009-05-15 * Some syntactic sugar for attribute sets: allow {x.y.z = ...;} as aEelco Dolstra5-0/+35
shorthand for {x = {y = {z = ...;};};}. This is especially useful for NixOS configuration files, e.g. { services = { sshd = { enable = true; port = 2022; }; }; } can now be written as { services.sshd.enable = true; services.sshd.port = 2022; } However, it is currently not permitted to write { services.sshd = {enable = true;}; services.sshd.port = 2022; } as this is considered a duplicate definition of `services.sshd'.
2008-08-14 * Added an experimental feature suggested by Andres: ellipses ("...")Eelco Dolstra7-5/+20
in attribute set pattern matches. This allows defining a function that takes *at least* the listed attributes, while ignoring additional attributes. For instance, {stdenv, fetchurl, fuse, ...}: stdenv.mkDerivation { ... }; defines a function that requires an attribute set that contains the specified attributes but ignores others. The main advantage is that we can then write in all-packages.nix aefs = import ../bla/aefs pkgs; instead of aefs = import ../bla/aefs { inherit stdenv fetchurl fuse; }; This saves a lot of typing (not to mention not having to update all-packages.nix with purely mechanical changes). It saves as much typing as the "args: with args;" style, but has the advantage that the function arguments are properly declared (not implicit in what the body of the "with" uses).
2008-08-14 * @-patterns as in Haskell. For instance, in a function definitionEelco Dolstra5-0/+32
f = args @ {x, y, z}: ...; `args' refers to the argument as a whole, which is further pattern-matched against the attribute set pattern {x, y, z}.
2008-08-14 * Refactoring: combine functions that take an attribute set andEelco Dolstra5-10/+16
functions that take a single argument (plain lambdas) into one AST node (Function) that contains a Pattern node describing the arguments. Current patterns are single lazy arguments (VarPat) and matching against an attribute set (AttrsPat). This refactoring allows other kinds of patterns to be added easily, such as Haskell-style @-patterns, or list pattern matching.
2008-08-11 * Removed the "valid values" feature. Nobody uses it anyway.Eelco Dolstra8-34/+4
2008-07-11 * Generalised the dependencyClosure primop to builtins.genericClosure,Eelco Dolstra3-0/+380
which is hopefully more useful. * New primops: length, mul, div.
2008-07-01 * Export the nix-env derivation name parsing and version comparisonEelco Dolstra3-0/+43
logic through the `parseDrvName' and `compareVersions' primops. This will allow expressions to easily check whether some dependency is a specific needed version or falls in some version range. See tests/lang/eval-okay-versions.nix for examples.
2008-02-05 * Doh.Eelco Dolstra1-1/+1
2008-02-05 * Regression test.Eelco Dolstra2-2/+9
2008-01-04 * New primop `unsafeDiscardStringContext' to get rid of stringEelco Dolstra2-0/+7
contexts. Needed to prevent unnecessary dependencies when building the NixOS manual.
2007-12-06 * Syntax to escape '', ${.Eelco Dolstra2-2/+8
2007-11-30 * Added a new kind of multi-line string literal delimited by twoEelco Dolstra2-0/+108
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.
2007-11-21 * New primop `readFile' to get the contents of a file as a string.Eelco Dolstra2-0/+2
2007-08-18 primop functions listToAttrs (+test), __isAttrs, __trace addedMarc Weber2-0/+9
new configuration style proposal in lib/default-unstable.nix
2007-05-15 * Allow empty argument lists in function definitions (e.g., `{}:Eelco Dolstra2-0/+2
bla'). Also allow trailing commas (`{x, y,}: ...') as a unintented consequence. Hopefully the reduce/reduce conflict won't cause any problems.
2007-01-29 New primitives:Eelco Dolstra4-3/+32
* `sub' to subtract two numbers. * `stringLength' to get the length of a string. * `substring' to get a substring of a string. These should be enough to allow most string operations to be expressed.
2007-01-14 * Option --argstr for passing string arguments easily. (NIX-75)Eelco Dolstra3-0/+17
2007-01-13 * Canonicalise ASTs in `nix-instantiate --eval': remove positionEelco Dolstra4-4/+4
info, sort attribute sets.
2006-12-12 * New built-in function `builtins.attrNames' that returns theEelco Dolstra2-0/+12
names of the attributes in an attribute set.
2006-10-17 * Another test.Eelco Dolstra1-0/+1
2006-10-17 * Fix the tests wrt the AST changes, i.e., Str(s) -> Str(s, []), andEelco Dolstra18-18/+20
the semantic changes.
2006-10-11 * Removed URIs from the evaluator (NIX-66). They are now just anotherEelco Dolstra3-3/+3
kind of notation for strings.
2006-10-02 * Finally, a real "let" syntax: `let x = ...; ... z = ...; in ...'.Eelco Dolstra2-0/+15
2006-09-24 * Primop `toPath' to convert a string to a path.Eelco Dolstra2-0/+4
* Primop `pathExists' to check for path existence.
2006-09-24 * Builtin function `getEnv' for getting environment variables.Eelco Dolstra2-0/+2
2006-09-24 * lessThan primitive for integer comparison.Eelco Dolstra1-1/+4
2006-09-22 * Builtin function `add' to add integers.Eelco Dolstra7-23/+45
* Put common test functions in tests/lang/lib.nix.
2006-09-22 * Added a builtin function `isList' to test whether a value is a list.Eelco Dolstra2-0/+20
With this primitive, a list-flattening function can be implemented (NIX-55, example is in tests/lang/eval-okay-flatten.nix).
2006-09-22 * Builtin functions `head' and `tail' to return the head and tail ofEelco Dolstra2-0/+14
list. Useful for lots of things, such as implementing a fold function (see NIX-30, example is in tests/lang/eval-okay-list.nix).
2006-09-22 * New builtin functions builtins.{hasAttr, getAttr} to check forEelco Dolstra2-0/+11
attribute existence and to return an attribute from an attribute set, respectively. Example: `hasAttr "foo" {foo = 1;}'. They differ from the `?' and `.' operators in that the attribute name is an arbitrary expression. (NIX-61)
2006-09-01 * Allow "$" in strings as long as they are not followed by "{". (TooEelco Dolstra2-1/+2
bad flex doesn't have lexical restrictions, the current solution isn't quite right...)
2006-08-30 * Okay, that's a bit harder than expected.Eelco Dolstra1-0/+0
2006-08-30 * TDD: == should do a deep equality test, i.e., it should strictlyEelco Dolstra2-0/+4
evaluate its arguments.
2006-08-24 * New primop __toXML (or builtins.toXML) to convert an expression toEelco Dolstra2-0/+2
an XML representation stored in a string. This should be useful to pass structured information to builders.
2006-08-23 * New primop: abort "error message".Eelco Dolstra1-0/+1
2006-08-23 * A new primop `builtins', which returns an attribute set containingEelco Dolstra2-0/+13
all the primops. This allows Nix expressions to test for new primops and take appropriate action if they're not available. For instance, rather than calling a primop `foo' directly, they could say `if builtins ? foo then builtins.foo ... else ...'.
2006-08-22 * Urgh (see NIX-56).Eelco Dolstra1-1/+0
2006-08-17 * Test for `nix-instantiate --eval-only --xml'.Eelco Dolstra3-0/+56