about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2014-05-29 Fix testEelco Dolstra2-2/+2
2014-05-26 Make the Nix search path declarativeEelco Dolstra2-1/+2
Nix search path lookups like <nixpkgs> are now desugared to ‘findFile nixPath <nixpkgs>’, where ‘findFile’ is a new primop. Thus you can override the search path simply by saying let nixPath = [ { prefix = "nixpkgs"; path = "/my-nixpkgs"; } ]; in ... <nixpkgs> ... In conjunction with ‘scopedImport’ (commit c273c15cb13bb86420dda1e5341a4e19517532b5), the Nix search path can be propagated across imports, e.g. let overrides = { nixPath = [ ... ] ++ builtins.nixPath; import = fn: scopedImport overrides fn; scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; builtins = builtins // overrides; }; in scopedImport overrides ./nixos
2014-05-26 Ensure that -I flags get included in nixPathEelco Dolstra1-1/+1
Also fixes #261.
2014-05-26 Add constant ‘nixPath’Eelco Dolstra2-2/+9
It contains the Nix expression search path as a list of { prefix, path } sets, e.g. [ { path = "/nix/var/nix/profiles/per-user/root/channels/nixos"; prefix = ""; } { path = "/etc/nixos/configuration.nix"; prefix = "nixos-config"; } { path = "/home/eelco/Dev/nix/inst/share/nix/corepkgs"; prefix = "nix"; } ]
2014-05-26 Add primop ‘scopedImport’Eelco Dolstra4-0/+16
‘scopedImport’ works like ‘import’, except that it takes a set of attributes to be added to the lexical scope of the expression, essentially extending or overriding the builtin variables. For instance, the expression scopedImport { x = 1; } ./foo.nix where foo.nix contains ‘x’, will evaluate to 1. This has a few applications: * It allows getting rid of function argument specifications in package expressions. For instance, a package expression like: { stdenv, fetchurl, libfoo }: stdenv.mkDerivation { ... buildInputs = [ libfoo ]; } can now we written as just stdenv.mkDerivation { ... buildInputs = [ libfoo ]; } and imported in all-packages.nix as: bar = scopedImport pkgs ./bar.nix; So whereas we once had dependencies listed in three places (buildInputs, the function, and the call site), they now only need to appear in one place. * It allows overriding builtin functions. For instance, to trace all calls to ‘map’: let overrides = { map = f: xs: builtins.trace "map called!" (map f xs); # Ensure that our override gets propagated by calls to # import/scopedImport. import = fn: scopedImport overrides fn; scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; # Also update ‘builtins’. builtins = builtins // overrides; }; in scopedImport overrides ./bla.nix * Similarly, it allows extending the set of builtin functions. For instance, during Nixpkgs/NixOS evaluation, the Nixpkgs library functions could be added to the default scope. There is a downside: calls to scopedImport are not memoized, unlike import. So importing a file multiple times leads to multiple parsings / evaluations. It would be possible to construct the AST only once, but that would require careful handling of variables/environments.
2014-05-22 Disable parallel.sh testEelco Dolstra1-1/+2
It breaks randomly: http://hydra.nixos.org/build/11152871
2014-05-02 Fix Debian testsEelco Dolstra1-0/+1
These actually run as root in a VM, so they get confused. http://hydra.nixos.org/build/10775854
2014-04-15 Fix test evaluationEelco Dolstra2-5/+5
2014-03-10 If a dynamic attribute name evaluates to null, remove it from the setShea Levy2-0/+2
2014-02-26 DohEelco Dolstra1-1/+1
2014-02-26 Test trace and addErrorContextEelco Dolstra1-0/+4
2014-02-26 Test some more primopsEelco Dolstra9-7/+24
2014-02-26 Test executables in NARsEelco Dolstra2-0/+6
2014-02-26 Test nix-env --switch-generationEelco Dolstra1-0/+6
2014-02-26 Test nix-env --setEelco Dolstra1-0/+6
2014-02-26 Test the -b and -s flags of nix-store -qEelco Dolstra1-0/+12
2014-02-26 Test ~/.nix-defexprEelco Dolstra1-14/+17
2014-02-26 Test nix-store --switch-profile and more daemon actionsEelco Dolstra2-51/+70
2014-02-26 Test nix-store -q --rootsEelco Dolstra1-0/+2
2014-02-26 Test nix-store -lEelco Dolstra1-1/+11
2014-02-26 Test nix-store --optimiseEelco Dolstra1-0/+17
2014-02-26 Add a test for nix-store --dump-db / --load-dbEelco Dolstra2-1/+21
2014-02-19 nix-instantiate: Rename --eval-only to --eval, --parse-only to --parseEelco Dolstra2-6/+6
2014-02-17 Test nix-store --verify-path and --repair-pathEelco Dolstra1-0/+18
2014-02-17 Add a test for repairing pathsEelco Dolstra5-8/+56
2014-02-06 Clean up a test warningEelco Dolstra1-1/+1
2014-02-06 Drop dependency on ‘expr’Eelco Dolstra1-2/+2
http://hydra.nixos.org/build/8715639 Not sure why this causes a failure now.
2014-02-01 Fix logging testEelco Dolstra2-2/+1
2014-02-01 Fix the nix-profile testEelco Dolstra2-3/+2
2014-02-01 Remove AutomakefilesEelco Dolstra1-52/+0
2014-02-01 Update Makefile variable namesEelco Dolstra1-3/+3
2014-01-30 Rename Makefile -> local.mkEelco Dolstra1-0/+0
2014-01-21 Merge branch 'master' into makeEelco Dolstra10-0/+67
Conflicts: src/libexpr/eval.cc
2014-01-14 Allow "bare" dynamic attrsShea Levy2-0/+18
Now, in addition to a."${b}".c, you can write a.${b}.c (applicable wherever dynamic attributes are valid). Signed-off-by: Shea Levy <shea@shealevy.com>
2014-01-08 Fix signed-binary-caches testEelco Dolstra1-1/+4
2014-01-08 Test whether Nix correctly checks the hash of downloaded NARsEelco Dolstra1-0/+14
2014-01-08 Support cryptographically signed binary cachesEelco Dolstra1-0/+8
NAR info files in binary caches can now have a cryptographic signature that Nix will verify before using the corresponding NAR file. To create a private/public key pair for signing and verifying a binary cache, do: $ openssl genrsa -out ./cache-key.sec 2048 $ openssl rsa -in ./cache-key.sec -pubout > ./cache-key.pub You should also come up with a symbolic name for the key, such as "cache.example.org-1". This will be used by clients to look up the public key. (It's a good idea to number keys, in case you ever need to revoke/replace one.) To create a binary cache signed with the private key: $ nix-push --dest /path/to/binary-cache --key ./cache-key.sec --key-name cache.example.org-1 The public key (cache-key.pub) should be distributed to the clients. They should have a nix.conf should contain something like: signed-binary-caches = * binary-cache-public-key-cache.example.org-1 = /path/to/cache-key.pub If all works well, then if Nix fetches something from the signed binary cache, you will see a message like: *** Downloading ‘http://cache.example.org/nar/7dppcj5sc1nda7l54rjc0g5l1hamj09j-subversion-1.7.11’ (signed by ‘cache.example.org-1’) to ‘/nix/store/7dppcj5sc1nda7l54rjc0g5l1hamj09j-subversion-1.7.11’... On the other hand, if the signature is wrong, you get a message like NAR info file `http://cache.example.org/7dppcj5sc1nda7l54rjc0g5l1hamj09j.narinfo' has an invalid signature; ignoring Signatures are implemented as a single line appended to the NAR info file, which looks like this: Signature: 1;cache.example.org-1;HQ9Xzyanq9iV...muQ== Thus the signature has 3 fields: a version (currently "1"), the ID of key, and the base64-encoded signature of the SHA-256 hash of the contents of the NAR info file up to but not including the Signature line. Issue #75.
2014-01-06 Merge branch 'dynamic-attrs-no-sugar' of github.com:shlevy/nixEelco Dolstra6-0/+24
2014-01-06 Disable the tail call testEelco Dolstra1-0/+0
On i686-linux, GCC stubbornly refuses to do tail-call optimisation. Don't know why. http://hydra.nixos.org/build/7300170
2013-12-31 Fold dynamic binds handling into addAttrShea Levy2-0/+2
Since addAttr has to iterate through the AttrPath we pass it, it makes more sense to just iterate through the AttrNames in addAttr instead. As an added bonus, this allows attrsets where two dynamic attribute paths have the same static leading part (see added test case for an example that failed previously). Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-31 Dynamic attrsShea Levy2-0/+18
This adds new syntax for attribute names: * attrs."${name}" => getAttr name attrs * attrs ? "${name}" => isAttrs attrs && hasAttr attrs name * attrs."${name}" or def => if attrs ? "${name}" then attrs."${name}" else def * { "${name}" = value; } => listToAttrs [{ inherit name value; }] Of course, it's a bit more complicated than that. The attribute chains can be arbitrarily long and contain combinations of static and dynamic parts (e.g. attrs."${foo}".bar."${baz}" or qux), which is relatively straightforward for the getAttrs/hasAttrs cases but is more complex for the listToAttrs case due to rules about duplicate attribute definitions. For attribute sets with dynamic attribute names, duplicate static attributes are detected at parse time while duplicate dynamic attributes are detected when the attribute set is forced. So, for example, { a = null; a.b = null; "${"c"}" = true; } will be a parse-time error, while { a = {}; "${"a"}".b = null; c = true; } will be an eval-time error (technically that case could theoretically be detected at parse time, but the general case would require full evaluation). Moreover, duplicate dynamic attributes are not allowed even in cases where they would be with static attributes ({ a.b.d = true; a.b.c = false; } is legal, but { a."${"b"}".d = true; a."${"b"}".c = false; } is not). This restriction might be relaxed in the future in cases where the static variant would not be an error, but it is not obvious that that is desirable. Finally, recursive attribute sets with dynamic attributes have the static attributes in scope but not the dynamic ones. So rec { a = true; "${"b"}" = a; } is equivalent to { a = true; b = true; } but rec { "${"a"}" = true; b = a; } would be an error or use a from the surrounding scope if it exists. Note that the getAttr, getAttr or default, and hasAttr are all implemented purely in the parser as syntactic sugar, while attribute sets with dynamic attribute names required changes to the AST to be implemented cleanly. This is an alternative solution to and closes #167 Signed-off-by: Shea Levy <shea@shealevy.com>
2013-12-31 Add the ExprBuiltin Expr type to the ASTShea Levy2-0/+4
Certain desugaring schemes may require the parser to use some builtin function to do some of the work (e.g. currently `throw` is used to lazily cause an error if a `<>`-style path is not in the search path) Unfortunately, these names are not reserved keywords, so an expression that uses such a syntactic sugar will not see the expected behavior (see tests/lang/eval-okay-redefine-builtin.nix for an example). This adds the ExprBuiltin AST type, which when evaluated uses the value from the rootmost variable scope (which of course is initialized internally and can't shadow any of the builtins). Signed-off-by: Shea Levy <shea@shealevy.com>
2013-11-25 Add support for ‘make installcheck’Eelco Dolstra4-15/+38
2013-11-19 Add a toJSON primopEelco Dolstra2-0/+12
2013-11-18 Add a primop unsafeGetAttrPos to return the position of an attributeEelco Dolstra2-0/+7
2013-11-18 Add a symbol __curPos that expands to the current source locationEelco Dolstra2-0/+6
I.e. an attribute set { file = <string>; line = <int>; column = <int>; }.
2013-11-18 Support quoted attribute names in -AEelco Dolstra2-4/+4
This is requires if you have attribute names with dots in them. So you can now say: $ nix-instantiate '<nixos>' -A 'config.systemd.units."postgresql.service".text' --eval-only Fixes #151.
2013-11-12 Add a test to check that tail calls run in bounded stack spaceEelco Dolstra2-0/+4
2013-10-24 Rename "attribute sets" to "sets"Eelco Dolstra1-1/+1
We don't have any other kind of sets so calling them attribute sets is unnecessarily verbose.
2013-10-24 Add a test of the type primopsEelco Dolstra2-0/+24